Re: Dumps core when calling gtk_dialog_run() from a focus_out_event handler



Scott Andrew Baillie <sbaillie bigpond net au> writes:

> Hi,
> 
> I am using a GtkEntry to get input from the user and
> I have connected to the focus_out_event signal so that
> I can validate the text typed into the GtkEntry when the
> focus leaves the GtkEntry.
> 
> >From within the focus_out_event handler, I am displaying
> a modal dialog box using the gtk_dialog_run() function.
> 
> This results in a core dump at run time when the focus
> leaves the GtkEntry.
> 
> I receive the following Gtk messages :
> 
> Gtk-WARNING **: GtkEntry - did not receive focus-out-event. If you
> connect a handler to this signal, it must return
> FALSE so the entry gets the event as well
> 
> Gtk-ERROR **: file gtkentry.c: line 4205 (blink_cb): assertion failed:
> (GTK_WIDGET_HAS_FOCUS (entry))
> aborting...
> 
> 
> Is it appropriate to show a modal dialog box from the focus_out_event
> handler ?

You can show a modal dialog from the focus-out-event, but entering
a recursive main loop is a bad idea, because the Entry won't know
that it lost focus until after the main loop returns. (The warning above 
is meant to be helpful, but we couldn't cover every possible case)

 Either - use gtk_window_set_modal() and gtk_window_show() and
  connect to ::response rather than gtk_dialog_

Or:

 Set up an idle rather than doing the action immediately.

Or:

 Use g_signal_connect_after()

Regards,
                                        Owen    



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