Re: Why is ChangeValue reentrant on a gtk_dialog_run?



On Tue, 11 Aug 2009 09:08:52 -0400
"Boggess Rod" <rboggess corefurnace com> wrote:


At the risk of beating a dead horse, I've figured out what the problem
is, I just don't understand why it's occurring or how to fix it.

If I call hscale's value-changed signal callback, I can return TRUE or
FALSE, and it behaves as expected.  If I create a static variable,
increment it, do a modulo 2 and return TRUE or FALSE on alternating
returns, in every case, it behaves as expected.

However, when I create a message dialog, it re-enters the
value-changed callback.  What's especially odd is that it re-enters
when the message dialog is created, not when it's actually
gtk_dialog_run().

Is this a threading issue?  I thought I was running the message dialog
modally, and if so, they should be on the same thread.  Anyone know
where I can find more info on this?

If you are writing a multi-threaded program and are trying to invoke
GTK+ functions from different theads without correctly using the GDK
global lock then you will find all sorts of problems, of which the one
you have observed will be the least of them.  Whether you happen to be
operating on a modal or non-modal dialog is irrelevant to that.

Personally I should avoid the GDK global lock and only call GDK/GTK+
functions in the main program thread, and communicate with it from
worker threads using eg g_idle_add*.  In a complicated program, you
will end up with a much cleaner and more intelligible program.  You will
have to do that anyway under windows as the GDK lock does not operate
under windows.

Chris




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