After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 592391 - Gtk2::MenuItem leaks in some cases
Gtk2::MenuItem leaks in some cases
Status: RESOLVED NOTABUG
Product: gnome-perl
Classification: Bindings
Component: Gtk2
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2009-08-19 22:54 UTC by Quentin Sculo
Modified: 2010-03-29 13:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (1.42 KB, application/x-perl)
2009-08-19 22:54 UTC, Quentin Sculo
  Details
sample circular ref between MenuItem and AccelLabel (259 bytes, text/x-perl)
2010-03-18 22:52 UTC, Kevin Ryde
  Details
docs of MenuItem circular ref (4.31 KB, patch)
2010-03-19 19:39 UTC, Kevin Ryde
committed Details | Review

Description Quentin Sculo 2009-08-19 22:54:37 UTC
Created attachment 141193 [details]
test case

A Gtk2::MenuItem (and Gtk2::CheckMenuItem ...) created with
my $item=Gtk2::MenuItem->new('sometext');
will not be automatically destroyed unless it has been added to a menu.
This does not happen if the Gtk2::MenuItem has been created with :
my $item=Gtk2::MenuItem->new;
even if a label is added afterward.

You might say that menuitem are almost always added to a menu :)
But in the case of menuitem used as proxy_menu_item for a Gtk2::ToolItem, the
menuitem won't be destroyed unless the menuitem has been added to the overflow
menu.
Comment 1 Kevin Ryde 2010-03-18 22:50:37 UTC
I think this is dodginess in Gtk itself.  A new_with_label makes an GtkAccelLabel with its "accel-widget" set to the item, which is a circular reference between the item and label.  Sample accel.pl attached.

I suppose the circularity is normally undone by a destroy() on the top GtkMenu calling destroy on all its children and sub-children.

Needing to call $item->destroy from perl is unpleasant, but I suppose it's not a bug strictly speaking.  We've got notes in Gtk2::Window on the need for explicit destroy() there.  Perhaps a similar bit in Gtk2::MenuItem, and a cross reference in Gtk2::AccelLabel.  I might have a go at a few words if no-one beats me to it.
Comment 2 Kevin Ryde 2010-03-18 22:52:50 UTC
Created attachment 156519 [details]
sample circular ref between MenuItem and AccelLabel
Comment 3 Kevin Ryde 2010-03-19 19:39:00 UTC
Created attachment 156579 [details] [review]
docs of MenuItem circular ref

I got to these few words, plus test cases exercising the truth of the words :-).
Comment 4 Torsten Schoenfeld 2010-03-29 13:52:03 UTC
Patch committed.  Thanks!  Since this is not a bug in the bindings, I'm marking
this report accordingly.