Re: Help with a multi-threaded application. Spot a crash.



On Fri, 1 Jun 2012 09:23:35 +0100
jcupitt gmail com wrote:
Hi again Osmo,

On 31 May 2012 17:50, Osmo Antero <osmoma gmail com> wrote:
Jcupitt:
Ok, g_idle_add() seems to need protection by gdk_threads_enter() and
leave().
Ref:
http://developer.gnome.org/gdk/stable/gdk-Threads.html#gdk-threads-add-idle

That's out of date. g_idle_add() does not need any locking by you.

I think you may be confusing this with the fact that with glib >= 2.32
it is no longer necessary to call g_thread_init() to make glib thread
safe, which is of course a completely different issue.

There is a proposal to deprecate the use of the GDK global lock, but in
a program which does use it, g_idle_add() does not exempt you from the
need to invoke the global lock in idle callbacks, either by doing it in
the idle callback yourself or by calling gdk_threads_add_idle().

The better approach is not to use the GDK global lock.

Chris



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]