Fix the bug of the first timer being added from idler.
We should start doing unit-test for ecore, accumulating these problems. Follows the test case: #include <Ecore.h> #include <Eina.h> static int _log_dom; #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) static int quiter(void *data) { INF("quit!"); ecore_main_loop_quit(); return 1; } static int idler(void *data) { INF("idler"); return 1; } static int cb1(void *data) { INF("cb1"); ecore_timer_add(0.0, quiter, NULL); return 0; } int main(void) { ecore_init(); _log_dom = eina_log_domain_register("test", EINA_COLOR_CYAN); /* * Create a main loop with just idlers, there is a special case * for just idlers without timers in ecore. * * From idler, add a timer that quits the application. It should * always quit. * * If it does not quit, then there is a bug of new timers not * being immediately detected and system never exits idle. */ INF("main: begin"); ecore_idler_add(cb1, NULL); ecore_idler_add(idler, NULL); ecore_main_loop_begin(); INF("main: end"); return 0; } SVN revision: 46405
This commit is contained in:
parent
fd7ed8786c
commit
dbc4a40265
|
@ -777,8 +777,7 @@ _ecore_main_loop_iterate_internal(int once_only)
|
|||
if (_ecore_main_select(0.0) > 0) have_event = 1;
|
||||
if (_ecore_signal_count_get() > 0) have_signal = 1;
|
||||
if (have_event || have_signal) break;
|
||||
next_time = _ecore_timer_next_get();
|
||||
if (next_time >= 0) goto start_loop;
|
||||
if (_ecore_timers_exists()) goto start_loop;
|
||||
if (do_quit) break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,7 @@ void _ecore_timer_shutdown(void);
|
|||
void _ecore_timer_cleanup(void);
|
||||
void _ecore_timer_enable_new(void);
|
||||
double _ecore_timer_next_get(void);
|
||||
int _ecore_timers_exists(void);
|
||||
int _ecore_timer_call(double when);
|
||||
|
||||
void _ecore_idler_shutdown(void);
|
||||
|
|
|
@ -409,6 +409,17 @@ _ecore_timer_enable_new(void)
|
|||
EINA_INLIST_FOREACH(timers, timer) timer->just_added = 0;
|
||||
}
|
||||
|
||||
int
|
||||
_ecore_timers_exists(void)
|
||||
{
|
||||
Ecore_Timer *timer = timers;
|
||||
|
||||
while ((timer) && (timer->delete_me))
|
||||
timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next;
|
||||
|
||||
return !!timer;
|
||||
}
|
||||
|
||||
static inline Ecore_Timer *
|
||||
_ecore_timer_first_get(void)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue