FinishTransaction fails

Under what conditions does GoDocument.FinishTransaction return false?
I’ve stepped through ensuring that the corresponding StartTransaction succeeded, and SkipsUndoManager is false.

It’s a little bit complicated, but basically GoUndoManager.EndTransaction(bool commit, String presentationname) returns true when the following conditions are all true:

  • commit is true
  • there is a CurrentEdit, and it is non-empty
  • this call ends the outermost transaction
    Otherwise it returns false.
    If your problem is a result of too many EndTransactions, then it might be useful to set GoUndoManager.ChecksTransactionLevel. This will put out a trace message when GoUndoManager.DocumentChanged is called when no transaction is ongoing. That might help pin down when the mismatched EndTransaction is occurring.
    If your problem is due to not enough EndTransactions, perhaps due to some exception that causes you to miss calling EndTransaction (use finally!), you’ll need to add code to check whether StartTransaction returns true when you expect it too. Unfortunately you can’t do that with all of the predefined transactions that GoDiagram implements, and if you overrode some method that is supposed to call EndTransaction but doesn’t, there isn’t any easy way to tell. The documentation says which methods do (or should do) what.


Actually the problem was that SuspendsUpdates was true. When this is the case, StartTransaction appears to succeed while EndTrasaction fails, if I am not mistaken.

We finally were led to the answer after numerous rereadings of the doc. We’re all wondering now, more than we were before, why there is not a comprehensive index to the documentation.

When GoDocument.SuspendsUpdates is true, all those calls to GoDocument.RaiseChanged (mostly from GoObject.Changed) turn into no-ops, instead of calling GoDocument.OnChanged.
GoDocument.OnChanged is responsible for calling GoUndoManager.DocumentChanged if there’s an UndoManager, as well as calling any GoDocument.Changed event handlers and doing other internal GoDocument bookkeeping.
So if GoDocument.SuspendsUpdates is true, no changes are being recorded by the undo manager. That means there won’t be a GoUndoManager.CurrentEdit, which is why EndTransaction returned false. Presumably CanUndo() and CanRedo() will always return false also.