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 95749 - managed child widgets destroyed when removed.
managed child widgets destroyed when removed.
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other other
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-10-14 19:21 UTC by Daniel
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program #1 (952 bytes, text/plain)
2002-10-14 19:21 UTC, Daniel
Details
test case #2 (913 bytes, text/plain)
2002-10-14 19:22 UTC, Daniel
Details

Description Daniel 2002-10-14 19:21:07 UTC
I have a class:

class MyFrame : public Gtk::Frame
{
public:
  MyFrame(string s) : Gtk::Frame(s), b(s) {
    add(b);
  }

  virtual ~MyFrame() {
    cout << "MyFrame dtor" << endl;
  }
private:
  Gtk::Button b;
};

when it is erased from a vbox using:

vbox1.children().erase(vbox1.children().begin(), vbox1.children().end());

the destructor does not get called (see attached file test1.cc). If b is a
pointer (test2.cc) and I use manage in the ctor the dtor gets called when I
use vbox.chlidren().erase()... This bug (if it is a bug?) appeard first in
gtkmm-1.3.24.
Comment 1 Daniel 2002-10-14 19:21:45 UTC
Created attachment 11533 [details]
test program #1
Comment 2 Daniel 2002-10-14 19:22:38 UTC
Created attachment 11534 [details]
test case #2
Comment 3 Murray Cumming 2002-10-15 10:49:39 UTC
This is quite well-known behaviour, but it would be nice to prevent it.
Comment 4 Murray Cumming 2002-10-21 13:18:25 UTC
2002-10-21  Murray Cumming  <murrayc@usa.net>

	* Gtk::Container_Class:destroy_callback(): dynamic_cast<> child
	widgets to Widget*, instead of Container*, of course. This seems to fix
	lots of lifetime bugs.