ecore: avoid breaking next main loop start if quit occurs outside of loop
authorMike Blumenkrantz <zmike@samsung.com>
Fri, 19 Jul 2019 19:42:09 +0000 (15:42 -0400)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 23 Jul 2019 05:04:43 +0000 (14:04 +0900)
in the case where ecore_main_loop_quit() was called before ecore_main_loop_begin(),
the latter call would exit immediately without ever iterating the main loop

@fix

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9360

src/lib/ecore/ecore_main.c
src/lib/ecore/ecore_private.h

index b1bf4ed..121edf6 100644 (file)
@@ -1257,6 +1257,7 @@ _ecore_main_loop_iterate_may_block(Eo *obj, Efl_Loop_Data *pd, int may_block)
 void
 _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
 {
+   pd->loop_active++;
    if (obj == ML_OBJ)
      {
 #ifdef HAVE_SYSTEMD
@@ -1320,11 +1321,13 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
         pd->do_quit = 0;
 #endif
      }
+   pd->loop_active--;
 }
 
 void
 _ecore_main_loop_quit(Eo *obj, Efl_Loop_Data *pd)
 {
+   if (!pd->loop_active) return;
    pd->do_quit = 1;
    if (obj != ML_OBJ) return;
 #ifdef USE_G_MAIN_LOOP
index 4c957c9..51d4afd 100644 (file)
@@ -162,6 +162,7 @@ struct _Efl_Loop_Data
 
    int                  idlers;
    int                  in_loop;
+   unsigned int         loop_active;
 
    struct {
       int               high;