Re: Gtk2 perl core dump

On Nov 26, 2004, at 6:39 PM, Ross McFarland wrote:

On Fri, 2004-11-26 at 11:31, Chris LaReau wrote:
I haven't gone much further looking into it as I'm fairly new to Gtk2, and haven't done much serious GUI programming since the era of the Motif/OpenLook turf wars, but I would appreciate any help or workarounds for this.

welcome to modern times. gtk+ is much, much less painful to the brain than motif. :-)

i didn't track down exactly what was going on, but it's a pretty safe assumption that using add and remove on a vbox to change out widgets is dangerous.

it appears that it's not adding and removing widgets that is bad in and of itself, it's adding and removing widgets in the midst of a focus change sequence, when the widget you just removed is the next one in the sequence. i added another entry widget between the two that were interacting, and the crash went away. still, adding and removing widgets like this isn't necessary, since what you're wanting to do appears to be merely to change the label, and seeing widgets pop in and out of existence can seriously confuse users, so it's not really something you want to do.


try out the attached

(you forgot the attachment ;-) does away with the whole remove/add stuff and just changes the checkbox's label which would seem like a much better route.

i would suggest exactly the same thing.

see attached

Description: Binary data

this sensitizes the checkbutton whenever it has a label; you could just as easily hide and show it if you really need the widget to disappear.

as far as finding the underlying bug (assuming that seg faults should never happen no matter whether the program is behaving or not.) translating to C and running that should tell you if it has anything to do with Gtk2. if it doesn't then filing a bug in gnome bugzilla with the attached C program would be the appropriate next step.

here's a quick C port (see attached dumpage.c, especially if you want to remind yourself why gtk2-perl is so much better than gtk+ in C). it exhibits similar behavior, but with a bunch of assertions about a bad object before actually crashing -- sometimes.

Attachment: dumpage.c
Description: Text document

in both cases (c and perl), it appears to be a misuse of gtk+ that causes the crash. by the time you get into the focus-out handler the second time, gtk+ wants to give the keyboard focus to the next widget in the focus chain, which you have just removed. this causes gtk+ to try to dereference a pointer that has already been freed, which results in the badness you know so well. note in the that i attached, even though the checkbutton is desensitized in the focus-out handler, it still gets keyboard focus. this hints to what i can't seem to find in the gtk+ source -- that the list of children involved in the focus chain is grabbed before the invocation of the handler for focus-out on your widget. it would be worth mentioning this to the gtk+ developers, as it suggests some sort of underlying problem in the focus chain code.

i'm with ross -- i don't fully know what you're trying to do, but i suspect that simply keeping a reference to the checkbutton and changing its label will be a much better way to do it.

I don't have a drinking problem,
'cept when i can't get drink.
  -- Tom Waits

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