Community
Participate
Working Groups
Build Identifier: GMF 2.3.1 It looks like the recent refactoring of codegen templates has introduced a bug when dealing with shortcuts in the semantic refresh of a diagram. In refreshSemantic(), the following is generated: ... for ( View v : getViewChildren() ) { if ( isMyDiagramElement(v) ) { knownViewChildren.add(v); } if ( v.getEAnnotation("Shortcut") != null && InfoDiagramUpdater.isShortcutOrphaned(v) ) { orphaned.add(v); } } ... A valid shortcut element is added to knownViewChildren and not to orphaned, which seems fine until you look later at the code where the diagram's semantic elements are processed, removing all valid view->element matches from knownViewChildren. In the end, invalid elements and valid shortcut elements are sent to the orphanage: orphaned.addAll(knownViewChildren); A temporary solution is to override the impl::diagram::update::CanonicalUpdate::_checkOrphanedShortcuts template to remove the valid shortcut view from knownViewChildren right away. «AROUND _checkOrphanedShortcuts(String orphanedCollectionVar, String viewVar) FOR gmfgen::GenDiagram» «IF containsShortcutsTo->notEmpty()-» if («viewVar».getEAnnotation("Shortcut") != null && «editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».isShortcutOrphaned(«viewVar»)) {«EXPAND xpt::Common::nonNLS» «orphanedCollectionVar».add(«viewVar»); } else { knownViewChildren.remove(v); } «ENDIF-» «ENDAROUND» Reproducible: Always Steps to Reproduce: 1. Create a shortcut from a related model on the diagram 2. Close the diagram 3. Reopen the diagram to see shortcut has vanished
Fix pushed into both 3.0 and 2.4.x maintenance stream
*** Bug 368154 has been marked as a duplicate of this bug. ***
Fixed since M4, closing the bug
It seems that this problem is not solved. GMF 3.0.0 still generates a refreshSemantic method that removes valid shortcuts from the diagram.
Hello, Looking at the problem, unable to reproduce right now, but probably understand what the problem is. I will try to deliver the fix to SR1.
Laurent, In the Taipan sample, after regenerating with GMFT 3.0R, I see the following code in the AquatoryCanonicalEditPolicy: // we care to check only views we recognize as ours and not shortcuts LinkedList<View> knownViewChildren = new LinkedList<View>(); for (View v : getViewChildren()) { if (isShortcut(v)) { if (TaiPanDiagramUpdater.isShortcutOrphaned(v)) { orphaned.add(v); } continue; } if (isMyDiagramElement(v)) { knownViewChildren.add(v); } } To my understanding it solves the problem (almost exactly the same way as you described it earlier). If you still have a problem, can you please attach the problematic XXXCanonicalEP here?
Created attachment 220721 [details] The requested xxCanonicalEditPolicy file
Hello Michael, The problem is still there. The shortcut is added to the knownViewChildren list, which in turn is added to the orphaned one and removed later on... Regards, Laurent
Hum, I see the expected generated code in your file. That is, at the line 140, there is a "continue;" which should prevent shrtcuts from being added to the knownViewChildren. Agree? I understand that you may still have a problem but its source is now different.