add a destructor for Gtkmm2ext::Pane that unparents the children.
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 6 Jun 2016 20:05:25 +0000 (16:05 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 6 Jun 2016 20:05:25 +0000 (16:05 -0400)
This seems to be required, although there is confusion in Gtkmm3 about this.

libs/gtkmm2ext/gtkmm2ext/pane.h
libs/gtkmm2ext/pane.cc

index f1d5bed092087d33513026984fc9e7e3959e3258..2fa35eb3a5248ef4c4faf62fc3597964b15e8f16 100644 (file)
@@ -55,6 +55,8 @@ class LIBGTKMM2EXT_API Pane : public Gtk::Container
        typedef std::list<Child> Children;
 
        Pane (bool horizontal);
+       ~Pane();
+
        void set_divider (std::vector<float>::size_type divider, float fract);
        float get_divider (std::vector<float>::size_type divider = 0);
        void set_child_minsize (Gtk::Widget const &, int32_t);
index ce99cc3d972cbbc783ae6e029cc5bf30c1a7b194..aa8e7d142b74655eaa3f0922eacf17dfdd1fe0a8 100644 (file)
@@ -44,6 +44,13 @@ Pane::Pane (bool h)
        }
 }
 
+Pane::~Pane ()
+{
+       for (Children::iterator c = children.begin(); c != children.end(); ++c) {
+               c->w->unparent ();
+       }
+}
+
 void
 Pane::set_child_minsize (Gtk::Widget const& w, int32_t minsize)
 {
@@ -149,12 +156,11 @@ Pane::on_remove (Widget* w)
 {
        for (Children::iterator c = children.begin(); c != children.end(); ++c) {
                if (c->w == w) {
+                       w->unparent ();
                        children.erase (c);
                        break;
                }
        }
-
-       w->unparent ();
 }
 
 void