X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4e3e485bc855bb6aa3e3e7978eac9fb5eea0287e..f369c7c2841c0534424f2c184783c1a2070012cf:/src/gtk1/tbargtk.cpp

diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp
index 06885d5341..f45f4e9112 100644
--- a/src/gtk1/tbargtk.cpp
+++ b/src/gtk1/tbargtk.cpp
@@ -88,8 +88,8 @@ public:
         Init();
     }
 
-    wxToolBarTool(wxToolBar *tbar, wxControl *control)
-        : wxToolBarToolBase(tbar, control)
+    wxToolBarTool(wxToolBar *tbar, wxControl *control, const wxString& label)
+        : wxToolBarToolBase(tbar, control, label)
     {
         Init();
     }
@@ -246,9 +246,10 @@ wxToolBarToolBase *wxToolBar::CreateTool(int id,
                              clientData, shortHelpString, longHelpString);
 }
 
-wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
+wxToolBarToolBase *
+wxToolBar::CreateTool(wxControl *control, const wxString& label)
 {
-    return new wxToolBarTool(this, control);
+    return new wxToolBarTool(this, control, label);
 }
 
 //-----------------------------------------------------------------------------
@@ -285,6 +286,8 @@ bool wxToolBar::Create( wxWindow *parent,
         return false;
     }
 
+    FixupStyle();
+
     GtkOrientation orient;
     GtkToolbarStyle gtkStyle;
     GetGtkStyle(style, &orient, &gtkStyle);
@@ -479,19 +482,26 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
     return true;
 }
 
-bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *toolBase)
+bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase)
 {
     wxToolBarTool *tool = (wxToolBarTool *)toolBase;
 
     switch ( tool->GetStyle() )
     {
         case wxTOOL_STYLE_CONTROL:
-            tool->GetControl()->Destroy();
+            // don't destroy the control here as we can be called from
+            // RemoveTool() and then we need to keep the control alive;
+            // while if we're called from DeleteTool() the control will
+            // be destroyed when wxToolBarToolBase itself is deleted
             break;
 
         case wxTOOL_STYLE_BUTTON:
             gtk_widget_destroy( tool->m_item );
             break;
+
+        default:
+            wxFAIL_MSG( "unknown tool style" );
+            return false;
     }
 
     InvalidateBestSize();