These are deprecated and will be killed in short time, stop using them!
Recommendations:
* ecore-txt: use eina_str_convert, drop in replacement, just sed.
* ecore-config: convert your code to use eet + Eet_Data_Descriptors
directly, it is simpler and faster, but requires you to change your
code. Consider using eet_data_descriptor_file_new() and
eet_eina_file_data_descriptor_class_set() or
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(). Then describe your type
with EET_DATA_DESCRIPTOR_ADD_*().
SVN revision: 46494
this will have compilers to completely compile out log statements
using levels greater than the given number.
this is defined in config.h, thus C files should include this before
including Eina.h, as should be the case for all files (IOW: if it does
not work for some file, that file already have a bug).
SVN revision: 46482
If an fd_handler created a recursive main loop (just called
ecore_main_loop_begin()), then this recursive main loop should
continue to process fd_handlers from there and on, thus
fd_handler_current (and win32_handler_current) was added. When going
back from recursion, the current iterator should be updated properly.
This patch also fixes the deletion of fd_handler 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.
PS: win32 code is untested (or even compiled).
The following test case used to crash but not anymore:
#include <Ecore.h>
#include <Eina.h>
#include <unistd.h>
static int _log_dom;
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
static Ecore_Fd_Handler *handle;
static int a[2], b[2];
static int cb2(void *data, Ecore_Fd_Handler *h)
{
INF("cb2 - delete cb1 handle");
ecore_main_fd_handler_del(handle);
ecore_main_loop_quit(); /* quits inner main loop */
return 0;
}
static int cb1(void *data, Ecore_Fd_Handler *h)
{
unsigned char ch = 222;
INF("cb1: begin");
INF(" add cb2");
ecore_main_fd_handler_add(b[0], ECORE_FD_READ, cb2, NULL, NULL, NULL);
INF(" wake up pipe b");
if (write(b[1], &ch, 1) != 1)
ERR("could not write to pipe b");
INF(" inner main loop begin (recurse)");
ecore_main_loop_begin(); /* will it crash due
* ecore_main_fd_handler_del(handle)
* inside cb2()? It used to!
*/
INF("cb1: end");
ecore_main_loop_quit(); /* quits outer main loop */
return 0;
}
int main(void)
{
unsigned char ch = 111;
ecore_init();
_log_dom = eina_log_domain_register("test", EINA_COLOR_CYAN);
pipe(a);
pipe(b);
/*
* Creating a new main loop from inside an fd_handler 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_main_fd_handler_add
(a[0], ECORE_FD_READ, cb1, NULL, NULL, NULL);
INF("main: wake up pipe a");
if (write(a[1], &ch, 1) != 1)
ERR("could not write to pipe a");
ecore_main_loop_begin();
INF("main: end");
return 0;
}
SVN revision: 46443
If an event handler/filter created a recursive main loop (just called
ecore_main_loop_begin()), then this recursive main loop should
continue to process events/handlers/filters from there and on, thus
event_current/event_filter_current/event_handler_current were
added. When going back from recursion, the current iterator should be
updated properly.
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_Event_Handler *handle;
static int cb2(void *data, int type, void *event)
{
INF("cb2 - delete cb1 handle");
ecore_event_handler_del(handle);
ecore_main_loop_quit(); /* quits inner main loop */
return 0;
}
static int cb1(void *data, int type, void *event)
{
Ecore_Event *e;
INF("cb1: begin");
INF(" add cb2");
type = ecore_event_type_new();
ecore_event_handler_add(type, cb2, NULL);
e = ecore_event_add(type, NULL, NULL, NULL);
INF(" add event to trigger cb2: event=%p", e);
INF(" inner main loop begin (recurse)");
ecore_main_loop_begin(); /* will it crash due
* ecore_event_handler_del(handle) inside
* cb2()? It used to!
*/
INF("cb1: end");
ecore_main_loop_quit(); /* quits outer main loop */
return 0;
}
int main(void)
{
Ecore_Event *e;
int type;
ecore_init();
_log_dom = eina_log_domain_register("test", EINA_COLOR_CYAN);
/*
* Creating a new main loop from inside an event 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.
*/
type = ecore_event_type_new();
INF("main: begin");
handle = ecore_event_handler_add(type, cb1, NULL);
e = ecore_event_add(type, NULL, NULL, NULL);
INF(" add event to trigger cb1: event=%p", e);
INF(" main loop begin");
ecore_main_loop_begin();
INF("main: end");
return 0;
}
SVN revision: 46419
Add reference counting to events, event filters and event handlers so
they can recurse main loops.
Note that the required "continuation" when entering main loops is not
there, thus recursion will restart and this will fail badly in lots of
cases. This should be fixed in future commits.
SVN revision: 46417
recursive main loops.
Unlike idlers, timers seems to work reasonably well with main loops, I
*think* they might fail since it used a boolean to flag running as
opposed to a reference count with incremental increments/decrements. I
could not write a test case to demonstrate so.
The now code should be simpler, particularly the
_ecore_timer_call(). It will also consider the previous position when
entering recursive main loops, preserving the order.
Deletion of timers are delegated to ecore_main.c, that was already
calling _ecore_timer_cleanup() after timers were executed.
SVN revision: 46416
If an idle_exiter created a recursive main loop (just called
ecore_main_loop_begin()), then this recursive main loop should
continue to process idle_exiters from there and on, thus
idle_exiter_current was added. When going back from recursion, the
current iterator should be updated properly.
This patch also fixes the deletion of idle_exiters 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_Exiter *handle;
static int idler(void *data)
{
INF("idler");
return 1;
}
static int timer(void *data)
{
INF("timer (exited idle!)");
return 0;
}
static int exit_idle(void *data)
{
INF("add request (timer) to exit idle");
ecore_timer_add(0.0, timer, NULL);
return 0;
}
static int cb2(void *data)
{
INF("cb2 - delete cb1 handle");
ecore_idle_exiter_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_exiter_add(cb2, NULL);
INF(" add exit idler");
ecore_idler_add(exit_idle, NULL);
INF(" inner main loop begin (recurse)");
ecore_main_loop_begin(); /* will it crash due ecore_idle_exiter_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_exiter 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_exiter_add(cb1, NULL);
ecore_idler_add(idler, NULL);
ecore_idler_add(exit_idle, NULL);
ecore_main_loop_begin();
INF("main: end");
return 0;
}
SVN revision: 46410
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
If an idler created a recursive main loop (just called
ecore_main_loop_begin()), then this recursive main loop should
continue to process idlers from there and on, thus idler_current was
added. When going back from recursion, the current iterator should be
updated properly.
This patch also fixes the deletion of idlers 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_Idler *handle;
static int idler(void *data)
{
INF("idler");
return 1;
}
static int cb2(void *data)
{
INF("cb2 - delete cb1 handle");
ecore_idler_del(handle);
ecore_main_loop_quit(); /* quits inner main loop */
return 0;
}
static int cb1(void *data)
{
INF("cb1: begin");
INF(" add cb2");
ecore_idler_add(cb2, NULL);
INF(" inner main loop begin (recurse)");
ecore_main_loop_begin(); /* will it crash due ecore_idler_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 idler 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_idler_add(cb1, NULL);
ecore_idler_add(idler, NULL);
ecore_main_loop_begin();
INF("main: end");
return 0;
}
SVN revision: 46406
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