Another problem with IsModified!

Hi all, I have read all the posts on various issues with IsModified, but they mostly seem to refer to people not being able to set it to false, the reasons for which I do understand. My problem is the reverse.

I am running an UndoManager, but in a special circumstance I want to forget about all the past changes, (by which I mean lose the Undo list) so I call UndoManager.Clear(). This seems to reset IsModified to false, so my Save button greys-out (and my document title loses the asterisk) even though I haven’t actually saved my changes. I cannot seem to force IsModified back to True, except by a very nasty approach of making a temporary change to a GoObject on the diagram, which also requires a Start+FinishTransaction() which puts a dummy entry in the Undo list which looks untidy. This is all a bit messy. Have I missed a simple solution?

This is my pseudo-code:

MouseClickEventToDoSpecialStuff()
{
bool oldModState = IsModified;
UndoManager.Clear(); // Forget the past
StartTransaction();
// Make changes to document here that I don’t want to ever undo
AbortTransaction(); //Don’t keep a record to undo

if( oldModState == true && IsModified == false)
{
// IsModified = True; Nice but doesn’t work so…
// I have to force an object to change here
StartTransction();
ChangeAnObjectInTheDocument();
FinishTransaction("");
}
}

To completely clear the GoDocument state with respect to UndoManager, you have to set GoDocument.UndoManager.

tempUndo = UndoManager;
UndoManager.Clear();
UndoManager = null;
UndoManager = tempUndo; // or you could create a new UndoManager.
isModified = true;
I haven't tested this, but it looks like it should work reading through the code.

Thanks Jake, this does indeed do the job :-)
Cheers