3 messages in org.gnome.gtk-perl-listRe: GtkEntry - did not receive focus-...
FromSent OnAttachments
Daniel KasakSep 21, 2005 7:30 pm 
muppetSep 21, 2005 10:34 pm 
Daniel KasakSep 21, 2005 10:55 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: GtkEntry - did not receive focus-out-event.Actions...
From:Daniel Kasak (dka@nusconsulting.com.au)
Date:Sep 21, 2005 10:55:00 pm
List:org.gnome.gtk-perl-list

muppet wrote:

This is a lot easier to understand with a timeline:

- focus into GtkEntry - GtkEntry installs timeout for cursor blinking - focus out of entry - GtkEntry emits focus-out-event - your handler runs **before the default handler**. - your handler traps exception and creates dialog box - dialog box runs nested event loop - event processing continues, focus goes to another widget - entry's cursor blink timeout is still installed, and runs again. entry does not have focus, but timeout has run, so the widget is in an invalid state and calls g_error() with a nastygram. - default handler runs, uninstalls cursor blink timeout

The problem is that you're allowing the event loop to run in your handler for focus-out.

The solution is to get the entry's default handler to run before you do anything that can run a main loop. There are two easy solutions:

a) use signal_connect_after to have your handler run *after* the default handler for focus-out-event instead of before.

b) leave the signal connected normally, but in your "catch" block, instead of running the dialog right then, defer it with an idle, like this:

if ($@) { # oh, crap. pop up the error message when the main loop is idle. Glib::Idle->add (sub { Gtk2::Ex::Dialogs::ErrorMsg->new_and_run( title => "Error in Query!", text => "DB Server says:\n$@" ); FALSE; # don't run again }); # return control immediately. return FALSE; }

and, of course, option c) is "do both."

Hope that works.

Yes, that makes it a lot clearer. Thanks :)