Backport fix for crash in wxCommandProcessor::Store. Closes #12027
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@65725 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -108,18 +108,6 @@ void wxCommandProcessor::Store(wxCommand *command)
|
||||
{
|
||||
wxCHECK_RET( command, _T("no command in wxCommandProcessor::Store") );
|
||||
|
||||
if ( (int)m_commands.GetCount() == m_maxNoCommands )
|
||||
{
|
||||
wxList::compatibility_iterator firstNode = m_commands.GetFirst();
|
||||
wxCommand *firstCommand = (wxCommand *)firstNode->GetData();
|
||||
delete firstCommand;
|
||||
m_commands.Erase(firstNode);
|
||||
|
||||
// Make sure m_lastSavedCommand won't point to freed memory
|
||||
if ( m_lastSavedCommand == firstNode )
|
||||
m_lastSavedCommand = wxList::compatibility_iterator();
|
||||
}
|
||||
|
||||
// Correct a bug: we must chop off the current 'branch'
|
||||
// so that we're at the end of the command list.
|
||||
if (!m_currentCommand)
|
||||
@@ -141,6 +129,18 @@ void wxCommandProcessor::Store(wxCommand *command)
|
||||
}
|
||||
}
|
||||
|
||||
if ( (int)m_commands.GetCount() == m_maxNoCommands )
|
||||
{
|
||||
wxList::compatibility_iterator firstNode = m_commands.GetFirst();
|
||||
wxCommand *firstCommand = (wxCommand *)firstNode->GetData();
|
||||
delete firstCommand;
|
||||
m_commands.Erase(firstNode);
|
||||
|
||||
// Make sure m_lastSavedCommand won't point to freed memory
|
||||
if ( m_lastSavedCommand == firstNode )
|
||||
m_lastSavedCommand = wxList::compatibility_iterator();
|
||||
}
|
||||
|
||||
m_commands.Append(command);
|
||||
m_currentCommand = m_commands.GetLast();
|
||||
SetMenuStrings();
|
||||
|
Reference in New Issue
Block a user