barbieri pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=04450c4ee03fd20271ec4f911667acea10ba1375
commit 04450c4ee03fd20271ec4f911667acea10ba1375 Author: Gustavo Sverzut Barbieri <barbi...@profusion.mobi> Date: Fri Dec 2 14:49:06 2016 -0200 eo: if EO_DEBUG, check if efl_super() object 'isa' the given class. A common error is to copy & paste efl_super() calls and forget to fix the class. If usin EO_DEBUG, then use efl_isa() to error. --- src/lib/eo/eo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index 9719034..e86f052 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -318,6 +318,11 @@ efl_super(const Eo *obj, const Efl_Class *cur_klass) { EO_CLASS_POINTER_GOTO(cur_klass, klass, err); + if (EINA_UNLIKELY(!_eo_is_a_obj(obj))) goto err_obj; +#ifdef EO_DEBUG + if (EINA_UNLIKELY(!efl_isa(obj, cur_klass))) goto err_obj_hierarchy; +#endif + /* FIXME: Switch to atomic operations intead of lock. */ eina_spinlock_take(&_super_class_lock); _super_class = klass; @@ -326,6 +331,14 @@ efl_super(const Eo *obj, const Efl_Class *cur_klass) err: _EO_POINTER_ERR("Class (%p) is an invalid ref.", cur_klass); return NULL; +err_obj: + _EO_POINTER_ERR("Object (%p) is an invalid ref, class=%p (%s).", obj, cur_klass, efl_class_name_get(cur_klass)); + return NULL; +#ifdef EO_DEBUG +err_obj_hierarchy: + _EO_POINTER_ERR("Object (%p) class=%p (%s) is not an instance of class=%p (%s).", obj, efl_class_get(obj), efl_class_name_get(obj), cur_klass, efl_class_name_get(cur_klass)); +#endif + return NULL; } EAPI Eina_Bool --