Re: Dialog box problem



On Thu, 2003-05-01 at 11:49, Allan Black wrote:
> This is one of those rare occasions where I'm trying to use a
> modal dialog box, and I'm stuck.
> 
> The dialog box is being run by g_main_iterate (actually from
> gmome_dialog_run_and_close) and I'm getting a warning:
> 
> GLib-WARNING **: g_main_iterate(): main loop already active in another thread
> 
> which is normally symptomatic of trying to run a main loop
> from a secondary thread (just like the message says :-).
> However, I'm NOT. The dialog box is being created within a
> UNIX signal handler, to allow me to deal gracefully with
> things like seg faults. (I'm actually testing it with SIGINTR
> a.k.a. Control-C, but the effect is the same).
> 
> What is happening, I believe, is that because the UNIX signal
> handler is "called" by the kernel on receipt of the signal,
> which occurs while g_main_poll is active (poll_waiting=TRUE),
> the g_main code "mistakenly thinks" that I'm trying to start
> a second main loop from a second thread. Sound reasonable?
> 
> In fact all I want to do is run a gtk_main_iteration() within
> the same (and only) thread.
> 
> Can anyone think of a way around this?

You *cannot* call GTK+ within a signal handler; the signal
handler could occur while GTK+ is modifying internal
data structures.

You have two choices:

 - Run your dialog box in a separate program (This is 
   how gnome-segv works, and is the only sensible thing
   to do for a SEGV, since at that point, the program
   is, by definition, in a hosed state.)

 - Write a byte down a pipe to yourself to wake up the
   main loop, and put up the dialog synchronously.

Regards,
                                        Owen





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