Commit Graph

533 Commits

Author SHA1 Message Date
Vincent Torri 141a2bb9a8 fix the Windows select function:
* On Windows, the values returned by pipe() are sockets.
   Hence they can be huge. Iterate over the list of "fds"
   instead of the max value
 * In the loop which iterates over the win32 handlers,
   we never go to the next element, so infinite loop...


SVN revision: 48807
2010-05-13 08:10:17 +00:00
Christopher Michael 54a9f1023d Fix 'return' with a value in function returning void.
SVN revision: 48754
2010-05-11 14:01:42 +00:00
Cedric BAIL 9522f7ab27 * ecore: make it possible to easily freeze/thaw animator.
NOTE: logic could be optimised as in some case we could just stop
	the timer also.


SVN revision: 48580
2010-05-03 16:21:39 +00:00
Carsten Haitzler 0dc8a3d0b7 \n--
SVN revision: 48371
2010-04-28 00:05:56 +00:00
Carsten Haitzler 9941fd4f8e better debug/error output for foreign fd issues.
SVN revision: 48370
2010-04-27 23:53:08 +00:00
Carsten Haitzler a08e3d18dc formatting.
SVN revision: 48354
2010-04-27 04:30:55 +00:00
Iván Briano e0dedc5eb9 Release lock before returning
SVN revision: 47980
2010-04-12 21:51:35 +00:00
Hannes Janetzek 5fd3adcc68 make ecore thread cancel work. someone knowing the internals should check this again.
SVN revision: 47866
2010-04-09 04:52:04 +00:00
Iván Briano d6f36ae575 'tis an array of pointers, not just a string
SVN revision: 47824
2010-04-07 22:09:26 +00:00
Vincent Torri 62b6d186cd revert. does not work
SVN revision: 47771
2010-04-05 18:20:49 +00:00
Vincent Torri ac2824d126 remove C99 features and use beautiful C89/BSD code
makes vc++ and win32 gcc/g++ happy


SVN revision: 47766
2010-04-05 17:48:08 +00:00
Vincent Torri 5751012d30 include process.h for vc++
SVN revision: 47760
2010-04-05 08:38:11 +00:00
Vincent Torri 898768c963 various fixes for vc++. I'll add the Visual Studio projects later
SVN revision: 47758
2010-04-05 08:26:48 +00:00
Carsten Haitzler e8d5b972b4 --enable-glib-integration-always <- option. can be disabled by
ecore_main_loop_glib_always_integrate_disable() before ecore_init()



SVN revision: 47360
2010-03-22 03:30:40 +00:00
Cedric BAIL d1ce34964b * ecore: Add memory statistic support. Set ECORE_MEM_STAT environment
variable to get them.


SVN revision: 47319
2010-03-18 14:43:39 +00:00
Gustavo Sverzut Barbieri dba2a95572 warnings--
Ecore now goes clean on -Wall -Wextra :-)



SVN revision: 46672
2010-02-28 23:27:47 +00:00
Vincent Torri e9b5f89824 F_SETFL and O_NONBLOCK are supported by evil
SVN revision: 46658
2010-02-28 17:38:24 +00:00
Gustavo Sverzut Barbieri e54bd066ec Convert everything to EINA_(TRUE|FALSE)
make it consistent.

By: Lucas de Marchi.



SVN revision: 46539
2010-02-27 00:01:10 +00:00
Christopher Michael 300d53a4f4 Patch from Brian Wang to fix the TRUE/FALSE --> EINA_TRUE/EINA_FALSE mess.
(NB: Win32/CE people may need to fix some TRUE/FALSE parts...couldn't test
those).

Thanks Brian :)



SVN revision: 46503
2010-02-26 05:56:49 +00:00
Cedric BAIL 816974ff0b * ecore: Match what doc when disabling thread support in ecore.
SVN revision: 46467
2010-02-25 15:26:38 +00:00
Gustavo Sverzut Barbieri 2d60db1c2b Fix fd_handlers when using recursive main loops.
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
2010-02-24 20:59:44 +00:00
Gustavo Sverzut Barbieri 50d0af9d5e Fix events when using recursive main loops.
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
2010-02-24 02:30:27 +00:00
Gustavo Sverzut Barbieri b9c3b58561 events (also filters and handlers) now have reference counting.
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
2010-02-24 01:16:00 +00:00
Gustavo Sverzut Barbieri 0bdbf9d147 rewrite ecore_timer internals to make it simpler and do better with
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
2010-02-24 00:27:04 +00:00
Gustavo Sverzut Barbieri 18b1bf46d7 move bitfield booleans to Eina_Bool.
using one bit with integers will just have room for 0 and -1, not 0 and 1.



SVN revision: 46412
2010-02-23 22:49:15 +00:00
Gustavo Sverzut Barbieri 0c24c76c5a Fix idle_exiters when using recursive main loops.
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
2010-02-23 22:25:35 +00:00
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
Gustavo Sverzut Barbieri 2bf063a77b Fix idlers when using recursive main loops.
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
2010-02-23 21:27:04 +00:00
Gustavo Sverzut Barbieri dbc4a40265 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
2010-02-23 21:04:38 +00:00
Gustavo Sverzut Barbieri 10b90e46c6 fix my coding style errors...
SVN revision: 46362
2010-02-22 20:09:44 +00:00
Gustavo Sverzut Barbieri 054da5beeb fix ecore-glib reentrance
if using ecore_main_loop_begin() multiple times (reentrant/recursive)
with glib doing threads, then it would deadlock since the same thread
would get the lock it already have.

multiple ecore_main_loop_begin() is required to implement WebKit's
alert/confirm/prompt dialogs since there is no async reply with
callbacks, rather one must return the value.

By: Lucas de Marchi



SVN revision: 46361
2010-02-22 20:09:03 +00:00
Vincent Torri f9f9b48c64 On Windows, ecore_exe_auto_limits_set() does nothing
SVN revision: 46331
2010-02-20 09:35:48 +00:00
Vincent Torri 5254d1a02e Windows: Add priority support when a child process is created
and add documentation for that.

SVN revision: 46330
2010-02-20 09:20:04 +00:00
Vincent Torri 7e08e3f23c improvements of the stderr and stdout redirections. There are
still lots of work to be done:

 * allow several redirections (only one for now...)
 * fix stdin redirection
 * fill empty functions

SVN revision: 46319
2010-02-19 19:23:47 +00:00
Carsten Haitzler e70759878c rfiddling wiht lop to try and get rid of pauses. i think i found it... plus a
bit of streamlining. need to test more widely now.



SVN revision: 46303
2010-02-19 08:00:44 +00:00
Carsten Haitzler 698f67609c aaaah bummer. (see comment)
SVN revision: 46243
2010-02-17 08:13:30 +00:00
Carsten Haitzler c13819b98a hmmmm try this. let me know if u see issues.
SVN revision: 46218
2010-02-16 16:52:02 +00:00
Christopher Michael 5306e3c050 No need to include sys/types twice.
SVN revision: 45954
2010-02-06 22:14:32 +00:00
Sebastian Dransfeld 75f4ccbbe5 More ecore_data to separate lib
SVN revision: 45782
2010-02-01 20:20:06 +00:00
Carsten Haitzler 34c68e86d5 make animator happen AT a vierual animator tick point.
SVN revision: 45614
2010-01-27 03:51:46 +00:00
Cedric BAIL 44193541f7 * ecore: Move ecore_job inside ecore.
Patch from Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>.


SVN revision: 45570
2010-01-25 21:59:21 +00:00
Vincent Torri 8744820a79 fix warnings
patch by Albin Tonnerre


SVN revision: 45433
2010-01-22 07:03:04 +00:00
Vincent Torri cad002c759 add stub Windows CE ecore_exe. Will be filled later
SVN revision: 45296
2010-01-18 18:16:50 +00:00
Vincent Torri d1bdb785b1 fix warnings on opensolaris
SVN revision: 45219
2010-01-16 13:44:25 +00:00
Christopher Michael ecb57ac1b8 Fix nasty formatting.
SVN revision: 44988
2010-01-08 19:49:05 +00:00
Vincent Torri c3dc62306f * fix Windows port of ecore_exe wrt to latest changes
* formatting


SVN revision: 44917
2010-01-06 06:56:23 +00:00
Gustavo Sverzut Barbieri 65a53edd34 Ecore_Exe improvements.
* add const to getters.

  * add ecore_exe_callback_pre_free_set(), enabling bindings to free
    their resources once the handle is destroyed.

  * fix some possible segv from not checking magic

  * check conditions before ecore_exe_send() does its work



SVN revision: 44916
2010-01-06 05:16:59 +00:00
Vincent Torri a4b0afb1e4 * move structures from ecore_private.h to the corresponding source files
* add 2 internal ecore_exe functions as ecore_signak.c uses Ecore_Exe members
   no test is done in those 2 functions
 * remove standard headers from ecore_private.h



SVN revision: 44862
2010-01-03 21:55:50 +00:00
Sebastian Dransfeld 0a9456ccf7 Remove duplication from ecore headers
Clean up Ecore.h and ecore_private.h

SVN revision: 44664
2009-12-22 21:15:12 +00:00
Cedric BAIL d8e1895350 * ecore: Use eina_log.
Patch from Mathieu Taillefumier.


SVN revision: 44637
2009-12-21 17:32:19 +00:00