]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxCommandProcessor::IsDirty() result after undoing everything after save.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 25 Jan 2012 00:05:12 +0000 (00:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 25 Jan 2012 00:05:12 +0000 (00:05 +0000)
IsDirty() returned false when all commands were undone after saving even
though it clearly should have returned true in this case.

Fix this and add comments explaining what happens in this method.

Closes #2862.

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

src/common/cmdproc.cpp

index ed7efb3e3f7f2a9d6a493d323bf14b3c881f22df..5e8a253ccbbeea631ee1ebc20eebcab533c600f0 100644 (file)
@@ -330,12 +330,26 @@ void wxCommandProcessor::ClearCommands()
 
 bool wxCommandProcessor::IsDirty() const
 {
-    if ( !m_currentCommand )
+    if ( m_commands.empty() )
+    {
+        // If we have never been modified, we can't be dirty.
         return false;
+    }
 
     if ( !m_lastSavedCommand )
+    {
+        // If we have been modified but have never been saved, we're dirty.
+        return true;
+    }
+
+    if ( !m_currentCommand )
+    {
+        // This only happens if all commands were undone after saving the
+        // document: we're dirty then.
         return true;
+    }
 
-    return m_lastSavedCommand != m_currentCommand;
+    // Finally if both iterators are valid, we may just compare them.
+    return m_currentCommand != m_lastSavedCommand;
 }