]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/tbargtk.cpp
updating the comment as well
[wxWidgets.git] / src / gtk1 / tbargtk.cpp
index 462561c522db9f6d87122ed0d5c3b3be29f0ed38..f45f4e9112e1ce23112001c72d4cdba8c1f4e92c 100644 (file)
@@ -482,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();