cxbrooks / test

Second test for bugzilla to git
0 stars 0 forks source link

Undo/Redo fails for simple situations involving ports #212

Open cxbrooks opened 14 years ago

cxbrooks commented 14 years ago

Note: the issue was created automatically with bugzilla2github tool

Original bug ID: BZ#330 From: @cxbrooks Reported version: 8.1.devel CC: pt-dev@chess.eecs.berkeley.edu

cxbrooks commented 14 years ago

Hauke reports:

  1. Link two actors directly with a link without relation vertex.
  2. Manually add a relation vertex to that relation (Cmd-click on the connection)
  3. Undo
  4. Redo
  5. Boom

Another similar bug:

  1. In a new blank canvas, place an input port, an output port and a relation (a diamond). Move the relation so that it is not in between the input port and the output port.
  2. Connect the input port and the output port.
    • Under Mac OS, place the mouse over the input port and then Command-click and drag to the output port
  3. Drag the end of the link from the output port to the relation
  4. Undo by doing Command-z
  5. Redo by doing Command-y

You will get the stack trace below.

I modified ptolemy.kernel.undo.UndoStackAttribute and added the following to the c'tor:

_debugging = true;

Note that this causes messages like: "Warning, _debugListeners was null, which means that _debugging was set to
true, but no listeners were added?" to appear. I removed those messages in the output below.

I also modified MoMLChangeRequest and set _DEBUG to true.

Below is a complete run that shows what is on the debug stack. My comments start with ####. It is easiest to start at the bottom and work up

bash-3.2$ $PTII/bin/vergil ** Executing MoML change:

------ in context .

=======> Pushing action onto undo stack:

...in context: .

======= Clearing redo stack.

** Executing MoML change:

------ in context .

=======> Pushing action onto undo stack:

...in context: .

======= Clearing redo stack.

** Executing MoML change:

------ in context .

=======> Pushing action onto undo stack:

...in context: .

======= Clearing redo stack.

** Executing MoML change:

------ in context .

Here is where we move the relation, completing step BZ#1 above.

=======> Pushing action onto undo stack:

...in context: .

Here is where we connect the input port and the output port, which

creates relation2. This is step BZ#2 above.

======= Clearing redo stack. ** Executing MoML change:

------ in context .

=======> Pushing action onto undo stack:

It might make more sense to do the unlinks first and then

deleteRelation, like what we do when we execute the change

...in context: .

======= Clearing redo stack.

Here, we do the unlinks first and then delete the relation.

This is step BZ#3

** Executing MoML change:

------ in context .

=======> Pushing action onto undo stack:

Again, this undo seems odd because we do the links to relation 2and then

create relation2. Then we unlink from port.

Compare this to the change request we executed for step BZ#2,

which was relation-link-link, but this step is link-link-relation-unlink

Perhaps it should be unlink-relation-link-link? In otherwords,

backwards from what we have? Should the commands be pushed onto

the undo stack in LIFO instead of FIFO?

...in context: .

======= Clearing redo stack.

Here, we are about to do the undo()

Oddly, we create relation2 after we do the links?

Note that the unlink from port to relation is at the end?

<====== Executing undo action:

...in context: .

Here, we actually do the MoML change

** Executing MoML change:

------ in context .

Note that what gets pushed on to the undo stack is the reverse

of the above. The problem will be that the port is not

multiport. Compare this to the MoML from step BZ#2, which is

relation-link-link, but we have link-deleteRelation-unlink-unlink.

Thsi should be unlink-unlink-deleteRelation-link

=======> Pushing action onto redo stack:

...in context: .

Here, we are about to process a redo()

Here's the MoMLChangeRequest we are going to execute, which will fail

<====== Executing redo action:

...in context: .

Below is the MoML change that causes the exception.

** Executing MoML change:

------ in context .

Here's the stack trace that appears after doing redo.

The problem occurs because we are linking to "port" to "relation", but

we have not done the unlink yet, so port has two links.

ptolemy.kernel.util.InternalErrorException: ChangeRequest failed (NOTE: there is no ChangeListener):

Because: Cannot insert a second inside link in a port that is not a multiport. in ..port at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:231) at ptolemy.moml.MoMLUndoEntry.execute(MoMLUndoEntry.java:107) at ptolemy.kernel.undo.UndoStackAttribute.redo(UndoStackAttribute.java:263) at ptolemy.kernel.undo.RedoChangeRequest._execute(RedoChangeRequest.java:96) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) at ptolemy.kernel.util.NamedObj.executeChangeRequests(NamedObj.java:732) at ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1757) at ptolemy.actor.CompositeActor.requestChange(CompositeActor.java:1594) at ptolemy.vergil.basic.BasicGraphFrame.redo(BasicGraphFrame.java:1187) at ptolemy.vergil.basic.BasicGraphFrame$RedoAction.actionPerformed(BasicGraphFrame.java:3318) at javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:3230) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1573) at javax.swing.JComponent.processKeyBinding(JComponent.java:2766) at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:255) at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:204) at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2843) at javax.swing.JComponent.processKeyBindings(JComponent.java:2835) at javax.swing.JComponent.processKeyEvent(JComponent.java:2729) at java.awt.Component.processEvent(Component.java:5379) at java.awt.Container.processEvent(Container.java:2010) at java.awt.Component.dispatchEventImpl(Component.java:4068) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1828) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:681) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:940) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:810) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:645) at java.awt.Component.dispatchEventImpl(Component.java:3941) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Window.dispatchEventImpl(Window.java:1801) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Caused by: ptolemy.kernel.util.IllegalActionException: Cannot insert a second inside link in a port that is not a multiport. in ..port at ptolemy.actor.IOPort.insertLink(IOPort.java:2036) at ptolemy.kernel.ComponentPort.insertInsideLink(ComponentPort.java:256) at ptolemy.moml.MoMLParser._processLink(MoMLParser.java:6170) at ptolemy.moml.MoMLParser.access$700(MoMLParser.java:205) at ptolemy.moml.MoMLParser$LinkRequest.execute(MoMLParser.java:7217) at ptolemy.moml.MoMLParser._processPendingRequests(MoMLParser.java:6306) at ptolemy.moml.MoMLParser.endElement(MoMLParser.java:892) at com.microstar.xml.XmlParser.parseETag(XmlParser.java:1026) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1098) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1104) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:481) at com.microstar.xml.XmlParser.doParse(XmlParser.java:159) at com.microstar.xml.XmlParser.parse(XmlParser.java:132) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1402) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1374) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1530) at ptolemy.moml.MoMLChangeRequest._execute(MoMLChangeRequest.java:289) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) ... 37 more Caused by: ptolemy.kernel.util.IllegalActionException: Cannot insert a second inside link in a port that is not a multiport. in ..port at ptolemy.actor.IOPort.insertLink(IOPort.java:2036) at ptolemy.kernel.ComponentPort.insertInsideLink(ComponentPort.java:256) at ptolemy.moml.MoMLParser._processLink(MoMLParser.java:6170) at ptolemy.moml.MoMLParser.access$700(MoMLParser.java:205) at ptolemy.moml.MoMLParser$LinkRequest.execute(MoMLParser.java:7217) at ptolemy.moml.MoMLParser._processPendingRequests(MoMLParser.java:6306) at ptolemy.moml.MoMLParser.endElement(MoMLParser.java:892) at com.microstar.xml.XmlParser.parseETag(XmlParser.java:1026) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1098) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1104) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:481) at com.microstar.xml.XmlParser.doParse(XmlParser.java:159) at com.microstar.xml.XmlParser.parse(XmlParser.java:132) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1402) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1374) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1530) at ptolemy.moml.MoMLChangeRequest._execute(MoMLChangeRequest.java:289) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) at ptolemy.moml.MoMLUndoEntry.execute(MoMLUndoEntry.java:107) at ptolemy.kernel.undo.UndoStackAttribute.redo(UndoStackAttribute.java:263) at ptolemy.kernel.undo.RedoChangeRequest._execute(RedoChangeRequest.java:96) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) at ptolemy.kernel.util.NamedObj.executeChangeRequests(NamedObj.java:732) at ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1757) at ptolemy.actor.CompositeActor.requestChange(CompositeActor.java:1594) at ptolemy.vergil.basic.BasicGraphFrame.redo(BasicGraphFrame.java:1187) at ptolemy.vergil.basic.BasicGraphFrame$RedoAction.actionPerformed(BasicGraphFrame.java:3318) at javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:3230) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1573) at javax.swing.JComponent.processKeyBinding(JComponent.java:2766) at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:255) at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:204) at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2843) at javax.swing.JComponent.processKeyBindings(JComponent.java:2835) at javax.swing.JComponent.processKeyEvent(JComponent.java:2729) at java.awt.Component.processEvent(Component.java:5379) at java.awt.Container.processEvent(Container.java:2010) at java.awt.Component.dispatchEventImpl(Component.java:4068) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1828) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:681) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:940) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:810) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:645) at java.awt.Component.dispatchEventImpl(Component.java:3941) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Window.dispatchEventImpl(Window.java:1801) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


What I think is happening here is that it is not sufficient to just reverse calls (link becomes unlink) in redo. I think we need to reverse the order.

Interestingly, if we use multiports instead of ports, we get a different error:

  1. File -> New -> Graph Editor
  2. Create an input multiport, and output multiport and a relation diamond, drag the diamond out of the way
  3. Connect the input multiport to the output multiport
    • Under Mac OS X, use Command-Click
  4. Drag one end of the connection to the relation
  5. Undo with Command-z
  6. Redo with Command-y

ptolemy.kernel.util.InternalErrorException: ChangeRequest failed (NOTE: there is no ChangeListener):

Because: Index: 0, Size: 0 at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:231) at ptolemy.moml.MoMLUndoEntry.execute(MoMLUndoEntry.java:107) at ptolemy.kernel.undo.UndoStackAttribute.redo(UndoStackAttribute.java:263) at ptolemy.kernel.undo.RedoChangeRequest._execute(RedoChangeRequest.java:96) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) at ptolemy.kernel.util.NamedObj.executeChangeRequests(NamedObj.java:732) at ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1757) at ptolemy.actor.CompositeActor.requestChange(CompositeActor.java:1594) at ptolemy.vergil.basic.BasicGraphFrame.redo(BasicGraphFrame.java:1187) at ptolemy.vergil.basic.BasicGraphFrame$RedoAction.actionPerformed(BasicGraphFrame.java:3318) at javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:3230) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1573) at javax.swing.JComponent.processKeyBinding(JComponent.java:2766) at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:255) at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:204) at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2843) at javax.swing.JComponent.processKeyBindings(JComponent.java:2835) at javax.swing.JComponent.processKeyEvent(JComponent.java:2729) at java.awt.Component.processEvent(Component.java:5379) at java.awt.Container.processEvent(Container.java:2010) at java.awt.Component.dispatchEventImpl(Component.java:4068) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1828) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:681) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:940) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:810) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:645) at java.awt.Component.dispatchEventImpl(Component.java:3941) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Window.dispatchEventImpl(Window.java:1801) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.LinkedList.entry(LinkedList.java:368) at java.util.LinkedList.get(LinkedList.java:313) at ptolemy.moml.MoMLParser._processUnlink(MoMLParser.java:6600) at ptolemy.moml.MoMLParser.access$900(MoMLParser.java:205) at ptolemy.moml.MoMLParser$UnlinkRequest.execute(MoMLParser.java:7258) at ptolemy.moml.MoMLParser._processPendingRequests(MoMLParser.java:6306) at ptolemy.moml.MoMLParser.endElement(MoMLParser.java:892) at com.microstar.xml.XmlParser.parseETag(XmlParser.java:1026) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1098) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1104) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:481) at com.microstar.xml.XmlParser.doParse(XmlParser.java:159) at com.microstar.xml.XmlParser.parse(XmlParser.java:132) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1402) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1374) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1530) at ptolemy.moml.MoMLChangeRequest._execute(MoMLChangeRequest.java:289) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) ... 37 more Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.LinkedList.entry(LinkedList.java:368) at java.util.LinkedList.get(LinkedList.java:313) at ptolemy.moml.MoMLParser._processUnlink(MoMLParser.java:6600) at ptolemy.moml.MoMLParser.access$900(MoMLParser.java:205) at ptolemy.moml.MoMLParser$UnlinkRequest.execute(MoMLParser.java:7258) at ptolemy.moml.MoMLParser._processPendingRequests(MoMLParser.java:6306) at ptolemy.moml.MoMLParser.endElement(MoMLParser.java:892) at com.microstar.xml.XmlParser.parseETag(XmlParser.java:1026) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1098) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1104) at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924) at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:481) at com.microstar.xml.XmlParser.doParse(XmlParser.java:159) at com.microstar.xml.XmlParser.parse(XmlParser.java:132) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1402) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1374) at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1530) at ptolemy.moml.MoMLChangeRequest._execute(MoMLChangeRequest.java:289) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) at ptolemy.moml.MoMLUndoEntry.execute(MoMLUndoEntry.java:107) at ptolemy.kernel.undo.UndoStackAttribute.redo(UndoStackAttribute.java:263) at ptolemy.kernel.undo.RedoChangeRequest._execute(RedoChangeRequest.java:96) at ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:171) at ptolemy.kernel.util.NamedObj.executeChangeRequests(NamedObj.java:732) at ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1757) at ptolemy.actor.CompositeActor.requestChange(CompositeActor.java:1594) at ptolemy.vergil.basic.BasicGraphFrame.redo(BasicGraphFrame.java:1187) at ptolemy.vergil.basic.BasicGraphFrame$RedoAction.actionPerformed(BasicGraphFrame.java:3318) at javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:3230) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1573) at javax.swing.JComponent.processKeyBinding(JComponent.java:2766) at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:255) at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:204) at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2843) at javax.swing.JComponent.processKeyBindings(JComponent.java:2835) at javax.swing.JComponent.processKeyEvent(JComponent.java:2729) at java.awt.Component.processEvent(Component.java:5379) at java.awt.Container.processEvent(Container.java:2010) at java.awt.Component.dispatchEventImpl(Component.java:4068) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1828) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:681) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:940) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:810) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:645) at java.awt.Component.dispatchEventImpl(Component.java:3941) at java.awt.Container.dispatchEventImpl(Container.java:2068) at java.awt.Window.dispatchEventImpl(Window.java:1801) at java.awt.Component.dispatchEvent(Component.java:3903) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)