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
This commit is contained in:
Vadim Zeitlin
2012-01-25 00:05:12 +00:00
parent ef20428e99
commit 812a21486d

View 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;
}
return m_lastSavedCommand != m_currentCommand;
if ( !m_currentCommand )
{
// This only happens if all commands were undone after saving the
// document: we're dirty then.
return true;
}
// Finally if both iterators are valid, we may just compare them.
return m_currentCommand != m_lastSavedCommand;
}