From: Vadim Zeitlin Date: Wed, 25 Jan 2012 00:05:12 +0000 (+0000) Subject: Fix wxCommandProcessor::IsDirty() result after undoing everything after save. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/812a21486dea91fc81edce69655d28fc1fdff2c3 Fix wxCommandProcessor::IsDirty() result after undoing everything after save. 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 --- diff --git a/src/common/cmdproc.cpp b/src/common/cmdproc.cpp index ed7efb3e3f..5e8a253ccb 100644 --- a/src/common/cmdproc.cpp +++ b/src/common/cmdproc.cpp @@ -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; }