efl/legacy/ecore/src/lib
Gustavo Sverzut Barbieri 1c3348513a Fix idle_enterers when using recursive main loops.
If an idle_enterer created a recursive main loop (just called
ecore_main_loop_begin()), then this recursive main loop should
continue to process idle_enterers from there and on, thus
idle_enterer_current was added. When going back from recursion, the
current iterator should be updated properly.

This patch also fixes the deletion of idle_enterers from recursive
main loops by reference counting them. This way, the node will not be
free()d inside inner loop cleanups and then crash when going back to
outer loop.

The following test case used to crash but not anymore:

#include <Ecore.h>
#include <Eina.h>

static int _log_dom;
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)

static Ecore_Idle_Enterer *handle;

static int idler(void *data)
{
    INF("idler");
    return 1;
}

static int cb2(void *data)
{
    INF("cb2 - delete cb1 handle");
    ecore_idle_enterer_del(handle);
    ecore_main_loop_quit(); /* quits inner main loop */
    return 0;
}

static int cb1(void *data)
{
    INF("cb1: begin");
    INF("    add cb2");
    ecore_idle_enterer_add(cb2, NULL);
    INF("    inner main loop begin (recurse)");
    ecore_main_loop_begin(); /* will it crash due ecore_idle_enterer_del(handle)
                              * inside cb2()? It used to!
                              */
    INF("cb1: end");

    ecore_main_loop_quit(); /* quits outer main loop */

    return 0;
}

int main(void)
{
    ecore_init();

    _log_dom = eina_log_domain_register("test", EINA_COLOR_CYAN);

    /*
     * Creating a new main loop from inside an idle_enterer callback,
     * and inside this new (inner) main loop deleting the caller
     * callback used to crash since the handle would be effectively
     * free()d, but when the recursion is over the pointer would be
     * used.
     */

    INF("main: begin");
    handle = ecore_idle_enterer_add(cb1, NULL);
    ecore_idler_add(idler, NULL);
    ecore_main_loop_begin();
    INF("main: end");
    return 0;
}




SVN revision: 46408
2010-02-23 22:13:42 +00:00
..
ecore Fix idle_enterers when using recursive main loops. 2010-02-23 22:13:42 +00:00
ecore_con never use macro defined by configure in an exported header 2010-02-23 13:11:54 +00:00
ecore_config even tho its going to be killed... fix it anyway. 2010-02-22 08:08:04 +00:00
ecore_data Make ecore_data enabled or disabled with configure. 2010-02-15 20:29:38 +00:00
ecore_directfb Ecore_Data gone 2010-01-15 21:47:27 +00:00
ecore_evas Update to new event callback signature. 2010-02-16 13:00:11 +00:00
ecore_fb This closes bug #507 2010-01-29 11:42:26 +00:00
ecore_file switch to eina_strlcpy 2010-01-27 20:59:26 +00:00
ecore_imf missing header 2010-01-26 23:32:06 +00:00
ecore_imf_evas fix warnings 2010-01-22 07:03:04 +00:00
ecore_input fix ecore_input shutdown 2010-02-06 10:13:41 +00:00
ecore_input_evas also more multitouch suport improvements. 2010-01-17 08:52:38 +00:00
ecore_ipc Remove dependency on Ecore_Data 2010-01-15 21:47:15 +00:00
ecore_quartz * ecore_cocoa: Improve Mac OS X support. 2009-10-22 11:08:01 +00:00
ecore_sdl Added missing compose values for SDL key events 2010-01-22 22:26:42 +00:00
ecore_txt don't link ecore_txt against eina 2010-02-15 19:54:59 +00:00
ecore_win32 Patch from Mathieu Taillefumier 2010-01-07 00:30:05 +00:00
ecore_wince Patch from Mathieu Taillefumier 2010-01-07 00:30:05 +00:00
ecore_x Add atoms/functions for keyboard geometry. This will be used w/ conformant 2010-02-23 20:53:34 +00:00
.cvsignore
Makefile.am More ecore_data to separate lib 2010-02-01 20:20:06 +00:00