From dee149f3aae2cc44ee5614dbfa0e467ae3237301 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 24 Nov 2017 16:19:21 +0900 Subject: [PATCH] elm_part: Mark as auto-unref before finalize This simplifies the IMPLEMENT macro, which can now be a proper function. Also, do not set a parent for the part object, as it's not useful and could mess up the refcount. --- src/lib/elementary/elm_part_helper.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/elementary/elm_part_helper.h b/src/lib/elementary/elm_part_helper.h index eef0d2f..fd07059 100644 --- a/src/lib/elementary/elm_part_helper.h +++ b/src/lib/elementary/elm_part_helper.h @@ -1,6 +1,9 @@ #ifndef _ELM_PART_HELPER_H #define _ELM_PART_HELPER_H +#define EFL_OBJECT_BETA +#define EFL_OBJECT_PROTECTED + #include "Elementary.h" #include "elm_priv.h" #include "efl_ui_layout_part_legacy.eo.h" @@ -72,18 +75,19 @@ _elm_part_initialize(Eo *proxy, Eo *obj, const char *part) EINA_SAFETY_ON_FALSE_RETURN_VAL(pd && obj && part, NULL); efl_allow_parent_unref_set(proxy, 1); - // efl_auto_unref_set(proxy, 1); + efl_auto_unref_set(proxy, 1); pd->part = eina_tmpstr_add(part); pd->obj = obj; return proxy; } -#define ELM_PART_IMPLEMENT(PART_CLASS, _obj, _part) ({ \ - Eo *proxy = efl_add(PART_CLASS, (Eo *) _obj, \ - _elm_part_initialize(efl_added, (Eo *) _obj, _part)); \ - efl_auto_unref_set(proxy, 1); \ - proxy; }) +static inline Eo * +ELM_PART_IMPLEMENT(const Efl_Class *part_klass, const Eo *obj, const char *part) +{ + return efl_add(part_klass, NULL, + _elm_part_initialize(efl_added, (Eo *) obj, part)); +} #define ELM_PART_OVERRIDE_ONLY_ALIASES(type, TYPE, typedata, aliases) \ EOLIAN static Efl_Object * \ -- 2.7.4