summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-01-29 11:56:34 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-02-21 13:40:46 -0800
commit83be87e4a44b45e8f500a95de0f3a3d511e35ea9 (patch)
tree81028b92d51cb7dad14bf164b797d3568660d56d /src
parent43c5d1305eca158be09eb7ef3e61a041e45d76a9 (diff)
ecore: add infrastructure to make it easy to enforce Efl.Loop_Model children lifecycle.
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Differential Revision: https://phab.enlightenment.org/D7862
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore/efl_loop_model.c27
-rw-r--r--src/lib/ecore/efl_loop_model.eo11
2 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/ecore/efl_loop_model.c b/src/lib/ecore/efl_loop_model.c
index f04a766acb..0f212f1283 100644
--- a/src/lib/ecore/efl_loop_model.c
+++ b/src/lib/ecore/efl_loop_model.c
@@ -7,6 +7,7 @@
7#include <Ecore.h> 7#include <Ecore.h>
8#include "Eo.h" 8#include "Eo.h"
9 9
10#include "ecore_private.h"
10#include "efl_loop_model.eo.h" 11#include "efl_loop_model.eo.h"
11 12
12typedef struct _Efl_Loop_Model_Watcher_Data Efl_Loop_Model_Watcher_Data; 13typedef struct _Efl_Loop_Model_Watcher_Data Efl_Loop_Model_Watcher_Data;
@@ -106,4 +107,30 @@ _efl_loop_model_efl_model_property_ready_get(Eo *obj, void *pd EINA_UNUSED, cons
106 return efl_future_then(obj, f); 107 return efl_future_then(obj, f);
107} 108}
108 109
110static void
111_noref_death(void *data EINA_UNUSED, const Efl_Event *event)
112{
113 efl_event_callback_del(event->object, EFL_EVENT_NOREF, _noref_death, NULL);
114 // For safety reason and in case multiple call to volatile has been made
115 // we check that there is still a parent at this point in EFL_EVENT_NOREF
116 efl_del(event->object);
117}
118
119static void
120_efl_loop_model_volatile_make(Eo *obj, void *pd EINA_UNUSED)
121{
122 // Just to make sure we do not double register this callback, we first remove
123 // any potentially previous one.
124 efl_event_callback_del(obj, EFL_EVENT_NOREF, _noref_death, NULL);
125 efl_event_callback_add(obj, EFL_EVENT_NOREF, _noref_death, NULL);
126}
127
128static void
129_efl_loop_model_efl_object_invalidate(Eo *obj, void *pd EINA_UNUSED)
130{
131 efl_event_callback_del(obj, EFL_EVENT_NOREF, _noref_death, NULL);
132
133 efl_invalidate(efl_super(obj, EFL_LOOP_MODEL_CLASS));
134}
135
109#include "efl_loop_model.eo.c" 136#include "efl_loop_model.eo.c"
diff --git a/src/lib/ecore/efl_loop_model.eo b/src/lib/ecore/efl_loop_model.eo
index 72e094f221..362b8bff09 100644
--- a/src/lib/ecore/efl_loop_model.eo
+++ b/src/lib/ecore/efl_loop_model.eo
@@ -1,7 +1,18 @@
1abstract @beta Efl.Loop_Model extends Efl.Loop_Consumer implements Efl.Model 1abstract @beta Efl.Loop_Model extends Efl.Loop_Consumer implements Efl.Model
2{ 2{
3 data: null; 3 data: null;
4 methods {
5 volatile_make {
6 [[To be called when a Child model is created by @Efl.Model.children_slice_get by the one creating the child object.
7
8 This function is used to properly define the lifecycle of the new Child Model object
9 and make sure that once it has 0 ref except its parent Model, it will be destroyed.
10 This function should only be called once per child. It is useful for @Efl.Model who
11 have a lot of children and shouldn't keep more than what is used in memory.]]
12 }
13 }
4 implements { 14 implements {
15 Efl.Object.invalidate;
5 Efl.Model.property_ready_get; 16 Efl.Model.property_ready_get;
6 } 17 }
7} 18}