]> git.saurik.com Git - wxWidgets.git/commitdiff
fix reparenting a control into wxToolBar
authorPaul Cornett <paulcor@bullseye.com>
Wed, 20 Jun 2007 17:49:13 +0000 (17:49 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Wed, 20 Jun 2007 17:49:13 +0000 (17:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46562 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/tbargtk.cpp

index 3bf93388d5064fb0f98c1a7be32ab1d7d310476c..935b5011d0ec1aefbc0ab3ec3a460ada579073a4 100644 (file)
@@ -363,9 +363,11 @@ void gtktoolwidget_size_callback( GtkWidget *widget,
 //-----------------------------------------------------------------------------
 
 static void wxInsertChildInToolBar( wxWindow* WXUNUSED(parent),
-                                    wxWindow* WXUNUSED(child) )
+                                    wxWindow* child)
 {
-    // we don't do anything here
+    // Child widget will be inserted into GtkToolbar by DoInsertTool. Ref it
+    // here so reparenting into wxToolBar doesn't delete it.
+    g_object_ref(child->m_widget);
 }
 
 // ----------------------------------------------------------------------------
@@ -653,6 +655,8 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
                                        (const char *) NULL,
                                        posGtk
                                       );
+            // release reference obtained by wxInsertChildInToolBar
+            g_object_unref(tool->GetControl()->m_widget);
 
             // connect after in order to correct size_allocate events
             g_signal_connect_after (tool->GetControl()->m_widget, "size_allocate",