X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/25af884d93f0ec95640b0d07a2aab348a15d9ac2..7b0ccb8a603b4f97740acc65d9429bb58f7ba1bd:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index abb467f5ca..0e6d905ab3 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -62,6 +62,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) wxToolBarToolBase::~wxToolBarToolBase() { delete m_dropdownMenu; + if ( IsControl() ) + GetControl()->Destroy(); } @@ -208,6 +210,7 @@ wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool) } m_tools.Insert(pos, tool); + tool->Attach(this); return tool; } @@ -314,17 +317,19 @@ wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) { // don't give any error messages - sometimes we might call RemoveTool() // without knowing whether the tool is or not in the toolbar - return (wxToolBarToolBase *)NULL; + return NULL; } wxToolBarToolBase *tool = node->GetData(); + wxCHECK_MSG( tool, NULL, "NULL tool in the tools list?" ); + if ( !DoDeleteTool(pos, tool) ) - { - return (wxToolBarToolBase *)NULL; - } + return NULL; m_tools.Erase(node); + tool->Detach(); + return tool; }