Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355218

Summary: [Editor] UMLEditor never removes its CommandStackListener
Product: [Modeling] MDT.UML2 Reporter: Nicolas Bros <nicolas.bros>
Component: CoreAssignee: Kenn Hussey <Kenn.Hussey>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: gdupe, Kenn.Hussey
Version: 3.1.0Flags: Kenn.Hussey: kepler+
Target Milestone: M2   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 354158    
Attachments:
Description Flags
A proposed fix Kenn.Hussey: iplog+

Description Nicolas Bros CLA 2011-08-19 09:29:13 EDT
The UMLEditor adds a CommandStackListener to its CommandStack in UMLEditor#initializeEditingDomain, but it doesn't remove it when closed.
This is not an issue for normal use, but we have a case where the CommandStack is shared with another editor. It causes an SWTException "widget is disposed" when the UMLEditor is closed.

Note that this is a problem that seems shared by every EMF editor (the reflexive EcoreEditor and every generated editor).

version : org.eclipse.uml2.uml.editor_3.1.100.v201009281840
Comment 1 Kenn Hussey CLA 2011-09-04 19:36:52 EDT
How have you customized the editor so that it shares its command stack? Perhaps the editor could also be customized (in the same place) so that the command listeners are removed?

If this is truly a shared problem, I'm inclined to fix it in EMF (by modifying the codegen template)...
Comment 2 Nicolas Bros CLA 2011-09-05 04:14:23 EDT
We have not customized the UML editor. We have added an action that opens a table model editor from a selection of EObjects, from which we get a model (this works in any model editor, not just the UML editor). To edit this model in our model table editor, we use the editing domain of the original (UML) editor through the interface IEditingDomainProvider which it implements. And the command stack is obtained through EditingDomain#getCommandStack.
Comment 3 Kenn Hussey CLA 2012-06-20 15:11:31 EDT
Ed's not so keen on doing anything in EMF to deal with this. To fix it in UML2, I would suggest having the UML editor implement CommandStackListener and remove itself from the command stack when it's disposed. We can perhaps look at this for Keppler (since it's effectively an API change).
Comment 4 Christian Damus CLA 2012-08-29 10:41:13 EDT
Created attachment 220467 [details]
A proposed fix

Attached a patch that fixes the problem, not by changing the inheritance structure of the UMLEditor class, but simply by refactoring the command-stack listener as a new protected field (following the example of other listeners).  This allows subclasses to intercept the listener before it is added to the command-stack, which I suppose is why the other similar fields all have protected visibility (if it were my choice, they would all be private).

Anyhow, this is an addition to the API, so the patch is based on the Kepler (master) branch.  The patch is in Git's e-mail patch format.
Comment 5 Kenn Hussey CLA 2012-08-29 15:34:42 EDT
The fix has been committed and pushed to the 'master' branch in git.
Comment 6 Kenn Hussey CLA 2012-08-31 14:18:38 EDT
An integration build containing the fix is now available.