+ if ( (int)m_commands.GetCount() == m_maxNoCommands )
+ {
+ wxList::compatibility_iterator firstNode = m_commands.GetFirst();
+
+ // Make sure m_lastSavedCommand won't point to freed memory
+ if ( m_lastSavedCommand && m_lastSavedCommand == firstNode )
+ m_lastSavedCommand = wxList::compatibility_iterator();
+
+ wxCommand *firstCommand = (wxCommand *)firstNode->GetData();
+ delete firstCommand;
+ m_commands.Erase(firstNode);
+ }
+