]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't compare invalid iterators in wxCommandProcessor::IsDirty().
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 25 Jan 2012 00:05:09 +0000 (00:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 25 Jan 2012 00:05:09 +0000 (00:05 +0000)
Check that m_lastSavedCommand is valid before comparing it with
m_currentCommand as comparing invalid iterators results in an assert in STL
build (and probably should also result in an assert in non-STL build too for
consistency).

Also move IsDirty() implementation out of line to make it easier to modify it
further in the future and because there is no real reason to keep it inline.

Closes #13465.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cmdproc.h
src/common/cmdproc.cpp

index 6072e7fda0fe222fc6d7bb490fbfbde39c99451e..4fa3e34c192a94fe317160c26307d1ca0b31bdc5 100644 (file)
@@ -97,10 +97,7 @@ public:
     virtual void ClearCommands();
 
     // Has the current project been changed?
-    virtual bool IsDirty() const
-    {
-        return m_currentCommand && (m_lastSavedCommand != m_currentCommand);
-    }
+    virtual bool IsDirty() const;
 
     // Mark the current command as the one where the last save took place
     void MarkAsSaved()
index 7de08c279063d0ab5ad45ff89b823c2d0b4d5c3b..ed7efb3e3f7f2a9d6a493d323bf14b3c881f22df 100644 (file)
@@ -328,4 +328,14 @@ void wxCommandProcessor::ClearCommands()
     m_lastSavedCommand = wxList::compatibility_iterator();
 }
 
+bool wxCommandProcessor::IsDirty() const
+{
+    if ( !m_currentCommand )
+        return false;
+
+    if ( !m_lastSavedCommand )
+        return true;
+
+    return m_lastSavedCommand != m_currentCommand;
+}