From 9b667ed06292bc4dfe4e67a69788f5961893a9bf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 5 Jul 2017 20:12:14 +0900 Subject: [PATCH] elm: Forbid calls to efl_part(obj, NULL) This in theory should only affect the EO API usage. In EO we don't want efl_part() to be used for NULL part. In other words, there is no "default" part in EO objects. Instead, those functions like text_set or content_set should simply be implemented by the object themselves. The legacy API on the other hand will make sure that the "part" argument is set to a non-NULL value before reaching this point. --- src/lib/elementary/elm_layout.c | 2 +- src/lib/elementary/elm_part_helper.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/elementary/elm_layout.c b/src/lib/elementary/elm_layout.c index 5353a7c..1f7e929 100644 --- a/src/lib/elementary/elm_layout.c +++ b/src/lib/elementary/elm_layout.c @@ -2381,7 +2381,7 @@ _elm_layout_efl_part_part(const Eo *obj, Elm_Layout_Smart_Data *sd EINA_UNUSED, { pd->obj = (Eo *) obj; pd->sd = efl_data_xref(pd->obj, ELM_LAYOUT_CLASS, proxy); - pd->part = part ? strdup(part) : NULL; + pd->part = strdup(part); pd->temp = 1; } diff --git a/src/lib/elementary/elm_part_helper.h b/src/lib/elementary/elm_part_helper.h index 55c50f3..3f4ae43 100644 --- a/src/lib/elementary/elm_part_helper.h +++ b/src/lib/elementary/elm_part_helper.h @@ -43,13 +43,14 @@ _ ## type ## _efl_part_part(const Eo *obj, typedata *priv EINA_UNUSED, const cha partdata *pd; \ Eo *proxy; \ \ + EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL); \ proxy = efl_add(TYPE ## _INTERNAL_PART_CLASS, (Eo *) obj); \ pd = efl_data_scope_get(proxy, TYPE ## _INTERNAL_PART_CLASS); \ if (pd) \ { \ pd->obj = (Eo *) obj; \ pd->sd = efl_data_xref(pd->obj, TYPE ## _CLASS, proxy); \ - pd->part = part ? strdup(part) : NULL; \ + pd->part = strdup(part); \ pd->temp = 1; \ } \ \ @@ -111,13 +112,14 @@ _ ## type ## _efl_part_part(const Eo *obj, typedata *priv EINA_UNUSED, const cha partdata *pd; \ Eo *proxy; \ \ + EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL); \ proxy = efl_add(TYPE ## _INTERNAL_PART_CLASS, (Eo *) obj); \ pd = efl_data_scope_get(proxy, SUPER ## _INTERNAL_PART_CLASS); \ if (pd) \ { \ pd->obj = (Eo *) obj; \ pd->sd = efl_data_xref(pd->obj, SUPER ## _CLASS, proxy); \ - pd->part = part ? strdup(part) : NULL; \ + pd->part = strdup(part); \ pd->temp = 1; \ } \ \ -- 2.7.4