Re: [maemo-developers] Glib main loop behavior
Hi, Am Dienstag, den 06.12.2005, 18:36 +0100 schrieb Samuel Abels: The problem is that my_callback_in_the_glib_loop() is only called when there is activity on the screen, such as the mouse pointer moving over the Xephyr window in the scratchbox environment. You have to call g_thread_init at the beginning (see http://developer.gnome.org/doc/API/2.0/glib/glib-Threads.html#g-thread-init). What is the reason for this behaviour, and is there a way around it? I would like to use the mechanism to work around Gtk not being thread safe. GTK is not really thread-safe, but if you really have to call GTK functions from within a thread, you have to place them between gtk_thread_enter() and gtk_thread_leave() calls and be careful to not nest these calls. Regards, Martin ___ maemo-developers mailing list maemo-developers@maemo.org https://maemo.org/mailman/listinfo/maemo-developers
Re: [maemo-developers] Glib main loop behavior
On Mi, 2005-12-07 at 14:16 +0100, Martin Grimme wrote: Am Dienstag, den 06.12.2005, 18:36 +0100 schrieb Samuel Abels: The problem is that my_callback_in_the_glib_loop() is only called when there is activity on the screen, such as the mouse pointer moving over the Xephyr window in the scratchbox environment. You have to call g_thread_init at the beginning Ouch, I should have known. Thanks for your help, of course it works. -Samuel -- -- | Samuel Abels | http://www.debain.org| | spam2 ad debain dod org | knipknap ad jabber dod org | -- ___ maemo-developers mailing list maemo-developers@maemo.org https://maemo.org/mailman/listinfo/maemo-developers
[maemo-developers] Glib main loop behavior
Hello, I am trying to hook a callback into the glib mainloop using g_idle_add() and have noticed that the behaviour appears to differ from (what I believe is) the way Gtk does this outside of Maemo. For example, in the following code: - gboolean my_callback_in_the_glib_loop(gpointer data) { g_print(Joe was here\n); return FALSE; } gpointer my_thread(gpointer data) { while (running) { g_idle_add(my_callback_in_the_glib_loop, NULL); do_something(); } return NULL; } void on_button_pressed(...) { ... g_thread_create(my_thread, NULL, FALSE, NULL); } - The problem is that my_callback_in_the_glib_loop() is only called when there is activity on the screen, such as the mouse pointer moving over the Xephyr window in the scratchbox environment. What is the reason for this behaviour, and is there a way around it? I would like to use the mechanism to work around Gtk not being thread safe. -Samuel -- -- | Samuel Abels | http://www.debain.org| | spam2 ad debain dod org | knipknap ad jabber dod org | -- ___ maemo-developers mailing list maemo-developers@maemo.org https://maemo.org/mailman/listinfo/maemo-developers