+ 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();
+ }
+