eo: Fix unnecessary ERR logs with eo_debug
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 28 Sep 2017 03:25:19 +0000 (12:25 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Thu, 28 Sep 2017 03:30:36 +0000 (12:30 +0900)
efl_data_scope_safe_get() is often used to assert that an object is of a
certain type, but assuming it may be NULL or not of the required type.
This means that encountering an invalid type is an error handled by the
caller (we return NULL), and shouldn't print out extra ERR() logs.

This fixes issues with E run under eo_debug. E's code was safe as it's
using evas_object_smart_data_get() and verifies whether the returned
value is NULL (which is expected for a rectangle, for instance).

@fix

src/lib/eo/eo.c

index 5e75cf9..49dc221 100644 (file)
@@ -2076,26 +2076,26 @@ err_klass:
 EAPI void *
 efl_data_scope_safe_get(const Eo *obj_id, const Efl_Class *klass_id)
 {
-#ifndef EO_DEBUG
    void *ret = NULL;
 
    if (!obj_id) return NULL;
    EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL);
    EO_CLASS_POINTER_GOTO(klass_id, klass, err_klass);
-   if (obj->destructed)
-     {
-        goto err_klass;
-     }
+   if (obj->destructed) goto err_klass;
 
    if (_eo_class_mro_has(obj->klass, klass))
-     ret = _efl_data_scope_safe_get(obj, klass);
+     {
+        ret = _efl_data_scope_safe_get(obj, klass);
+
+#ifdef EO_DEBUG
+        if (!ret && (klass->desc->data_size == 0))
+          ERR("Tried getting data of class '%s', but it has none.", klass->desc->name);
+#endif
+     }
 
 err_klass:
    EO_OBJ_DONE(obj_id);
    return ret;
-#else
-   return efl_data_scope_get(obj_id, klass_id);
-#endif
 }
 
 EAPI void *