A Gtk2::Bin subclass and a segfault



Hi Everyone,

  I'm  trying to  implement a  custom widget.  A particular  "technique"
(read: ugly trick) I use results in a segfault. If someone could run the
test program and  confirm the behaviour I'd be very  grateful, let alone
take a look  a the sources and  explain me what's going  on... I suspect
the culprit  is gtk+ itself  (2.10.14 here)  and not the  bingindgs, but
well...

  What I'm trying to achieve is:
- right click on a button, a popup menu shows.
- choose "Modify" from the menu, the button changes itself in an Gtk2::Entry
- The user modifies the text
  - if he presses Escape, changes are discarded
  - if he presses Enter, changes are confirmed. The widget becomes a button
    again, with a modified title. 

  This is  very similar to  what we are used  to do with  graphical file
managers, when we rename a file in a TreeView...

  Up till now everything works as I expect. Problems arise when I try to
make  the  "changes  confirmed"  action  happen  when  the  user  clicks
"outside" the  widget. The  right way to  do that, I  guess, would  be a
pointer grab. But  without going to that lenght, I  planned to chain the
Entry's "focus-out" event.

What happens is:
- Choose  modify, type some  text, click  on anything that  can actually
  grab the focus (i.e.: the quit button): OK
- As above, but press ESC to leave the entry: segfault
- As above, but click on another NameKey widget (it can't take the focus
  because I hijack left button clicks) : segfault

  Code stops at line 93 of NameKey.pm, right in the focus-out handler.
Perhaps when the event gets delivered, I already removed the widget...

  The widget  subclasses Gtk2::Bin, while  I'd have preferred  to derive
from Gtk2::Container,  and hide/show button/entry as  needed (right now,
instead i add/remove them on the fly).

  Thanks in advance for your time,
ciao,
--
Giuliano

Attachment: NameKey_test.tar.gz
Description: Binary data



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