Several fixes for removing/readding controls to the toolbar:
1. Don't destroy the control in wxToolBar::RemoveTool() as this prevents it from being added back with is the purpose of using RemoveTool() rather than DeleteTool(). 2. Call wxToolBarTool::Attach/Detach() from the base code, not just from wxMSW and wxMac (wasn't called by wxGTK at all). 3. Allow adding back the removed control tool in wxGTK. 4. Add test for removing/adding back a control tool to the sample. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user