GNOME Bugzilla – Bug 91404
Gtk::Button: memory leak when using mnemonic=true.
Last modified: 2004-12-22 21:47:04 UTC
We have detected that with the newer version of gtkmm (1.3.20+) the destructors of mangaged C++ wrapper objects never get called. This happens, because Gtk::Object::destroy_notify is not call for managed objects.
Created attachment 10642 [details] the test case as described
Have you tested this with 1.3.21?
Yes, it happens with gtkmm-1.3.21 too, both g++ and Forte C++.
I have added a corrected version of this test in tests/child_widget_managed. I believe that the problem is that you are calling Gtk::Main::quit() at an inappropriate time. The corrected test code shows how this should be done, using the Gtk::Main::run(window) overload. If you believe that this should work, then you should investigate whether the GtkButton or GtkWindow are actually destroyed. It might help to turn on the debugging messages in glib/glibmm/debug.h
Well, the use of hide() instead of quit() is okay. But the observed problem in this case comes from Gtk::Button. If we replace in tests/child_widget_managed/main.cc MyButton::MyButton() : Gtk::Button("Ok") { } by MyButton::MyButton() : Gtk::Button("_Ok", true) { } then the destructor of Gtk::Button ist not called no matter we call hide() or quit() to leave the main loop. There seems to be a registration problem with Gtk::Button, when mnemonic is activated.
This doesn't seem to be a bug in GTK+, as shown by this C test code.
Created attachment 10714 [details] main.cc (GTK+ C test)
This feels like a radical change, but everything seems to work: 2002-09-15 Murray Cumming <murrayc@usa.net> * gtk/src/container.ccg: Container_Class::destroy_callback(): We don't remove child widgets if they are not manage()ed, so that gtk_container_destroy will call destroy them properly. gtk_widget_destroy() will always succeed, but gtk_container_remove() isn't guarranteed to cause destruction. It is now clear that this callback was necessary, not just as a refcount hack - we really do need to remove non-manage()ed widgets, because SINKing them does not prevent them from being destroyed in gtk_container_destroy().
I don't think so. The whole point of that code is explained in the comment at the start of the method: // We need to remove non-manage()ed widgets to prevent gtk_container_destroy() from destroying them. // Contary to what we thought once, even non-floating (sunk) widgets are destroyed by gtk_container_destroy() It should have no effect on manage()s widgets.
Sorry, ignore that. Wrong bug.