summaryrefslogtreecommitdiff
path: root/src/lib/eo/eo_base_class.c
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2018-03-07 10:56:53 -0800
committerCedric Bail <cedric@osg.samsung.com>2018-03-07 10:56:53 -0800
commit83251edae77f9ae0c52edeb06512fbf0e2c39c8a (patch)
treeea037efa6bd5da91a4dbf3e2949865241b87cc48 /src/lib/eo/eo_base_class.c
parent012bcff80cbf0a89a708c5544d9defd81057b927 (diff)
eo: introduce invalidate and noref state.
This is just a first step. All user of destructor should be updated to move the code that rely on their efl_parent and on efl_provider_find to invalidate. Then we will be able to change the way efl_add and efl_del work to properly refcount things. efl_noref won't be triggered at the moment until both efl_parent_set(obj, NULL) and the last user ref are set to NULL. This is not what we want, but due to how user refcount is accounting parent at the moment, until all the code is move to rely on invalidate we can not fix this.
Diffstat (limited to 'src/lib/eo/eo_base_class.c')
-rw-r--r--src/lib/eo/eo_base_class.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index f1eff91..fe6da95 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -60,6 +60,7 @@ typedef struct
60 Eina_Bool parent_sunk : 1; // If parent ref has already been settled (parent has been set, or we are in add_ref mode 60 Eina_Bool parent_sunk : 1; // If parent ref has already been settled (parent has been set, or we are in add_ref mode
61 Eina_Bool allow_parent_unref : 1; // Allows unref to zero even with a parent 61 Eina_Bool allow_parent_unref : 1; // Allows unref to zero even with a parent
62 Eina_Bool has_destroyed_event_cb : 1; // No proper count: minor optimization triggered at destruction only 62 Eina_Bool has_destroyed_event_cb : 1; // No proper count: minor optimization triggered at destruction only
63 Eina_Bool invalidate : 1; // Object become invalide once it loose its parent
63} Efl_Object_Data; 64} Efl_Object_Data;
64 65
65typedef enum 66typedef enum
@@ -620,6 +621,9 @@ _efl_object_parent_set(Eo *obj, Efl_Object_Data *pd, Eo *parent_id)
620 ((parent_id) && (!_eo_id_domain_compatible(parent_id, obj)))) 621 ((parent_id) && (!_eo_id_domain_compatible(parent_id, obj))))
621 return; 622 return;
622 623
624 // Invalidated object can not be bring back to life
625 if (pd->invalidate) return ;
626
623 EO_OBJ_POINTER(obj, eo_obj); 627 EO_OBJ_POINTER(obj, eo_obj);
624 if (pd->parent) 628 if (pd->parent)
625 { 629 {
@@ -660,6 +664,7 @@ _efl_object_parent_set(Eo *obj, Efl_Object_Data *pd, Eo *parent_id)
660 else 664 else
661 { 665 {
662 pd->parent = NULL; 666 pd->parent = NULL;
667 if (prev_parent) efl_invalidate(obj);
663 if (prev_parent && !eo_obj->del_triggered) efl_unref(obj); 668 if (prev_parent && !eo_obj->del_triggered) efl_unref(obj);
664 } 669 }
665 670
@@ -694,6 +699,12 @@ _efl_object_finalized_get(Eo *obj_id, Efl_Object_Data *pd EINA_UNUSED)
694 return finalized; 699 return finalized;
695} 700}
696 701
702EOLIAN static Eina_Bool
703_efl_object_invalidated_get(Eo *obj_id EINA_UNUSED, Efl_Object_Data *pd)
704{
705 return pd->invalidate;
706}
707
697EOLIAN static Efl_Object * 708EOLIAN static Efl_Object *
698_efl_object_provider_find(const Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const Efl_Object *klass) 709_efl_object_provider_find(const Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const Efl_Object *klass)
699{ 710{
@@ -701,7 +712,6 @@ _efl_object_provider_find(const Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const
701 return NULL; 712 return NULL;
702} 713}
703 714
704
705/* Children accessor */ 715/* Children accessor */
706typedef struct _Eo_Children_Iterator Eo_Children_Iterator; 716typedef struct _Eo_Children_Iterator Eo_Children_Iterator;
707struct _Eo_Children_Iterator 717struct _Eo_Children_Iterator
@@ -2137,6 +2147,17 @@ _efl_object_finalize(Eo *obj, Efl_Object_Data *pd EINA_UNUSED)
2137 return obj; 2147 return obj;
2138} 2148}
2139 2149
2150static void
2151_efl_object_invalidate(Eo *obj EINA_UNUSED, Efl_Object_Data *pd)
2152{
2153 pd->invalidate = EINA_TRUE;
2154}
2155
2156static void
2157_efl_object_noref(Eo *obj EINA_UNUSED, Efl_Object_Data *pd EINA_UNUSED)
2158{
2159}
2160
2140EOLIAN static void 2161EOLIAN static void
2141_efl_object_class_constructor(Efl_Class *klass EINA_UNUSED) 2162_efl_object_class_constructor(Efl_Class *klass EINA_UNUSED)
2142{ 2163{