No changes, just slightly simplify the tool insertion code.
Added a helper DoInsertNewTool() function to avoid code duplication and ensure that we never forget to delete a new tool if inserting it into the toolbar failed. Also explicitly document that the tool passed to the public InsertTool() is not owned by the toolbar and so must be deleted by the caller if its insertion failed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -608,6 +608,17 @@ protected:
|
||||
// make the size of the buttons big enough to fit the largest bitmap size
|
||||
void AdjustToolBitmapSize();
|
||||
|
||||
// calls InsertTool() and deletes the tool if inserting it failed
|
||||
wxToolBarToolBase *DoInsertNewTool(size_t pos, wxToolBarToolBase *tool)
|
||||
{
|
||||
if ( !InsertTool(pos, tool) )
|
||||
{
|
||||
delete tool;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
||||
// the list of all our tools
|
||||
wxToolBarToolsList m_tools;
|
||||
|
Reference in New Issue
Block a user