ecore: migrate ecore_timer lifecycle to rely cleanly on Eo lifecycle.
authorCedric BAIL <cedric@osg.samsung.com>
Mon, 6 Jun 2016 21:59:06 +0000 (14:59 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 6 Jun 2016 22:41:24 +0000 (15:41 -0700)
src/lib/ecore/ecore_timer.c
src/lib/ecore/efl_loop_timer.eo

index 89f9616..a01d810 100644 (file)
@@ -32,6 +32,7 @@ struct _Efl_Loop_Timer_Data
    unsigned char  just_added : 1;
    unsigned char  frozen : 1;
    unsigned char  initialized : 1;
+   unsigned char  noparent : 1;
 };
 
 typedef struct _Efl_Loop_Timer_Data Efl_Loop_Timer_Data;
@@ -460,6 +461,33 @@ _efl_loop_timer_util_delay(Efl_Loop_Timer_Data *timer,
 }
 
 EOLIAN static void
+_efl_loop_timer_eo_base_parent_set(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *pd, Eo_Base *parent)
+{
+   Eina_Inlist *first;
+
+   first = eina_inlist_first(EINA_INLIST_GET(pd));
+   if (first == timers)
+     timers = eina_inlist_remove(timers, EINA_INLIST_GET(pd));
+   else if (first == suspended)
+     suspended = eina_inlist_remove(suspended, EINA_INLIST_GET(pd));
+
+   eo_parent_set(eo_super(obj, EFL_LOOP_USER_CLASS), parent);
+
+   if (eo_parent_get(obj) != parent)
+     return ;
+
+   if (parent != NULL)
+     {
+        _efl_loop_timer_util_instanciate(pd);
+        pd->noparent = EINA_FALSE;
+     }
+   else
+     {
+        pd->noparent = EINA_TRUE;
+     }
+}
+
+EOLIAN static void
 _efl_loop_timer_eo_base_destructor(Eo *obj, Efl_Loop_Timer_Data *pd)
 {
    Eina_Inlist *first;
@@ -481,14 +509,6 @@ _efl_loop_timer_eo_base_destructor(Eo *obj, Efl_Loop_Timer_Data *pd)
 void
 _efl_loop_timer_shutdown(void)
 {
-   Efl_Loop_Timer_Data *timer;
-
-   EINA_INLIST_FREE(timers, timer)
-     eo_del(timer->object);
-
-   EINA_INLIST_FREE(suspended, timer)
-     eo_del(timer->object);
-
    timer_current = NULL;
 }
 
@@ -557,11 +577,11 @@ _efl_loop_timer_next_get(void)
 
 static inline void
 _efl_loop_timer_reschedule(Efl_Loop_Timer_Data *timer,
-                      double when)
+                           double when)
 {
    if (timer->frozen) return;
 
-   if (timers)
+   if (timers && !timer->noparent)
      timers = eina_inlist_remove(timers, EINA_INLIST_GET(timer));
 
    /* if the timer would have gone off more than 15 seconds ago,
index 7b69ce4..022e9ee 100644 (file)
@@ -63,6 +63,7 @@ class Efl.Loop.Timer (Efl.Loop_User)
       Eo.Base.destructor;
       Eo.Base.finalize;
       Eo.Base.event_freeze;
+      Eo.Base.parent.set;
       /* XXX: can't document overridden methods
        * Pauses a running timer.
        *