Undo twice to undo adding a node


#1

Walter,

May I show you a video related with wrong ‘modified’ issue I referred in another topic a couple of days ago.

In this video, I add a node and undo once.
But still the status of the model is ‘modified’.
I do undo once again, then the model has changed to be ‘not-modified’.

I’m analyzing the “ExternalObjectsDropped” event listener, but I do not have any incomes.

    function onExternalObjectsDropped(e) {
        // stop any ongoing text editing
        if (_d.currentTool instanceof go.TextEditingTool) {
            _d.currentTool.acceptText(go.TextEditingTool.LostFocus);
        }

        // expand any "macros"
        _d.commandHandler.ungroupSelection();
    }

How may I analyze this issue.
Please help me.

Here’s the debug error message.

Change not within a transaction: !dChangedEvent.Insert parts: Layer “” new: -2 1
go-debug.js:35 Change not within a transaction: !d data: -2 new: -2
go-debug.js:35 Change not within a transaction: !d text: TextBlock("") old: Normal Node new:
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(NaN,NaN) new: Point(-104,33)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(-104,33) new: Point(-105,30)
go-debug.js:35 Change not within a transaction: !m loc: -2 old: -105 30 new: -75 45
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(-105,30) new: Point(-75,45)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(-105,30) new: Point(-75,45)
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(-75,45) new: Point(-60,45)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(-75,45) new: Point(-60,45)
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(-60,45) new: Point(-45,45)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(-60,45) new: Point(-45,45)
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(-45,45) new: Point(-30,60)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(-45,45) new: Point(-30,60)
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(-30,60) new: Point(-15,60)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(-30,60) new: Point(-15,60)
go-debug.js:35 Change not within a transaction: !dChangedEvent.Remove parts: Layer “” old: Node#5575(-2) 1


#2

Walter, I adds several logs in ‘ModelChanged’ listener.
And I found something strange.


DiagramManager.js:5027 onModelChanged:Insert null {category: “Normal”, key: -2, __gohashid: 5400}
go-debug.js:35 Change not within a transaction: !dChangedEvent.Insert parts: Layer “” new: -2 1
go-debug.js:35 Change not within a transaction: !d data: -2 new: -2
go-debug.js:35 Change not within a transaction: !d text: TextBlock("") old: Normal Node new:
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(NaN,NaN) new: Point(127,147)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(127,147) new: Point(120,150)
DiagramManager.js:5091 onModelChanged:StartedTransaction eg {tr: ya, Iw: “”, pn: “StartedTransaction”, ye: Y, ca: null, …}
DiagramManager.js:5094 onModelChanged:CommittingTransaction eg {tr: ya, Iw: “”, pn: “CommittingTransaction”, ye: Y, ca: null, …}
DiagramManager.js:4996 onModified dg {ca: E, ac: “Modified”, nx: null, Tw: null, sr: false}
DiagramManager.js:5097 onModelChanged:CommittedTransaction eg {tr: ya, Iw: “”, pn: “CommittedTransaction”, ye: Y, ca: null, …}
go-debug.js:35 Change not within a transaction: !m loc: -2 old: 120 150 new: 270 165
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(120,150) new: Point(270,165)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(120,150) new: Point(270,165)
go-debug.js:35 Change not within a transaction: !d position: -2 old: Point(270,165) new: Point(285,165)
go-debug.js:35 Change not within a transaction: !d location: -2 old: Point(270,165) new: Point(285,165)
DiagramManager.js:5041 onModelChanged:Remove {category: “Normal”, key: -2, __gohashid: 5400, loc: “285 165”, bounds: C} null
go-debug.js:35 Change not within a transaction: !dChangedEvent.Remove parts: Layer “” old: Node#5447(-2) 1
DiagramManager.js:5091 onModelChanged:StartedTransaction eg {tr: ya, Iw: “”, pn: “StartedTransaction”, ye: Y, ca: null, …}
DiagramManager.js:5027 onModelChanged:Insert null {category: “Normal”, key: -2, __gohashid: 5523}
DiagramManager.js:5094 onModelChanged:CommittingTransaction eg {tr: ya, Iw: “”, pn: “CommittingTransaction”, ye: Y, ca: null, …}
DiagramManager.js:5097 onModelChanged:CommittedTransaction eg {tr: ya, Iw: “”, pn: “CommittedTransaction”, ye: Y, ca: null, …}


This log shows that the process works by ‘insert’ - ‘remove’ - ‘insert’ sequence.
The first ‘insert’ adds a node and ‘remove’ removes it.
They has same __gohashid on newValue in insert and oldValue in remove.
The second ‘insert’ adds a new node again.
It has another __gohashid.

Still I don’t know what this means.


#3

I don’t understand why you are getting all of those “Change not within a transaction” warnings. When I implement “Changed” and “ModelChanged” DiagramEvent listeners in the Macros sample (which you seem to have started from), I do not get those warnings.

The cross-diagram drag-and-drop creates temporary nodes in the model and diagram when the mouse enters the target diagram. It removes them when leaving the diagram and when the drag-and-drop stops. But upon a successful drop, it obviously still needs to add the real data to the model and create the corresponding nodes and links for real in the diagram.


#4

Okay, now I understand the process that add a node.

I’ll find where “Change not within a transaction” occurred.


#5

Walter,

I’d like to check your latest reply again.

You explained ‘cross-diagram drag-and-drop’ to me.

By your explanation, is it expected that should undo twice to revert a node added by ‘cross-diagram drag-and-drop’?


#6

If you try any of the samples that have two diagrams that support dragging from one to the other, such as when one is a Palette, you will find that a successful drag-and-drop can be reversed with a single Undo command.


#7

walter, thank you for your confirmation.
I’m analyzing the ‘modified’ issue more exactly based on your confirmation.

I’m very suffered by the issue.
Quite many actions makes wrong ‘modified’ issue in my project.
It is now time to solve this problem that I’ve accumulated.
It should not be neglected anymore.
I’m doing my best to resolve this.
Please help me sometimes.


#8

I don’t have enough pertinent information to be able to guess about your problem. I suggest that you remove event handlers and listeners and method overrides, simplifying until you can narrow down the cause of the problems.