elm: Forbid calls to efl_part(obj, NULL)
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 5 Jul 2017 11:12:14 +0000 (20:12 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 5 Jul 2017 11:21:08 +0000 (20:21 +0900)
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
src/lib/elementary/elm_part_helper.h

index 5353a7c..1f7e929 100644 (file)
@@ -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;
      }
 
index 55c50f3..3f4ae43 100644 (file)
@@ -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; \
      } \
 \