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

Bug 235797

Summary: Refactoring opened model causes SWT to become unstable
Product: [Modeling] EMF Reporter: Victor Roldan Betancort <vroldanbet>
Component: ToolsAssignee: Dave Steinberg <davidms>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P1 CC: akarjakina, Ed.Merks, ed, Kenn.Hussey, richard.gronback, tikhomirov.artem, vsanchez
Version: unspecifiedFlags: richard.gronback: pmc_approved+
Ed.Merks: pmc_approved+
davidms: review+
Ed.Merks: review+
Kenn.Hussey: review+
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Template changes to eliminate bogus call to dispose
none
Fix for the EMF Transaction workbench integration example editor
none
Fix for GMF Editors none

Description Victor Roldan Betancort CLA 2008-06-05 07:12:27 EDT
Tested on a clean install of Eclipse 3.4 RC3 + EMF 2.4.0 RC3
Also tested in the Eclipse Modeling pack release

1. Create new proyect (non-java)
2. Create folder
3. Create two .ecore models inside that folder (for instance, test1.ecore and test2.ecore)
4. Open test1.ecore, then open test2.ecore. Keep both opened.
5. Refactor test2.ecore to test22.ecore

test2.ecore window should close, and test1.ecore window will appear without close button. The whole workbench will become unstable.
Comment 1 Ed Merks CLA 2008-06-05 08:01:20 EDT
I think this is purely a workbench issue:

org.eclipse.swt.SWTException: Graphic is disposed
	at org.eclipse.swt.SWT.error(SWT.java:3775)
	at org.eclipse.swt.SWT.error(SWT.java:3693)
	at org.eclipse.swt.SWT.error(SWT.java:3664)
	at org.eclipse.swt.graphics.Image.getBounds(Image.java:1145)
	at org.eclipse.swt.custom.CTabItem.drawSelected(CTabItem.java:378)
	at org.eclipse.swt.custom.CTabItem.onPaint(CTabItem.java:808)
	at org.eclipse.swt.custom.CTabFolder.drawTabArea(CTabFolder.java:1122)
	at org.eclipse.swt.custom.CTabFolder.onPaint(CTabFolder.java:2276)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:321)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1026)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1011)
	at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:1424)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3837)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4519)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2346)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3398)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:172)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:370)
	at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:317)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:558)
	at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:154)
	at org.eclipse.ltk.ui.refactoring.resource.RenameResourceWizard$RenameResourceRefactoringConfigurationPage.performFinish(RenameResourceWizard.java:119)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:622)
	at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:446)
	at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:472)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3801)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3400)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:144)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:156)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:37)
	at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startRenameResourceRefactoring(RefactoringExecutionStarter.java:441)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RenameResourceAction.run(RenameResourceAction.java:43)
	at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:110)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3801)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3400)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2387)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2351)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2203)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:112)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:615)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

I'll investigate a bit more....
Comment 2 Ed Merks CLA 2008-06-05 08:52:28 EDT
Created attachment 103726 [details]
Template changes to eliminate bogus call to dispose

The problem turns out to be that we are calling dispose on the editor directly and this causes the graphic for the editor to be disposed and thereby corrupts the whole IDE session.  We need to change the editor template and regenerate our editors to fix this as I've done in this patch.
Comment 3 Ed Merks CLA 2008-06-05 09:00:44 EDT
I can see that editors for UML and GMF need the same kind of attention; I'm not sure about OCL.  Given that the workbench becomes completely unusable after this problem, I think it's very important to give the issue attention.

IWorkbenchPart is pretty clear about not calling this method (though I have to think we did the dispose at some time in the past because it wasn't happening otherwise, but that might have been 5 years ago):

     * <p>
     * Clients should not call this method (the workbench calls this method at
     * appropriate times).
     * </p>
     */
    public void dispose();
Comment 4 Richard Gronback CLA 2008-06-05 09:24:40 EDT
This implies we need to regenerate our GMF editors for this release.  Adding Artem, as we'll need a corresponding bug/approval.
Comment 5 Christian Damus CLA 2008-06-05 09:44:10 EDT
Created attachment 103732 [details]
Fix for the EMF Transaction workbench integration example editor

Attached a patch for the EMF Transaction component's example transactional editor.
MDT OCL doesn't have any editors.

Committers, please review.
Comment 6 Christian Damus CLA 2008-06-05 09:46:03 EDT
Looks good to me, Ed.  Simple, safe, and doesn't impact clients unless they re-generate (which is optional at this stage in the release).  :-)
Comment 7 Christian Damus CLA 2008-06-05 09:48:19 EDT
(requesting review of my patch #103732 by David and Kenn)
Comment 8 Dave Steinberg CLA 2008-06-05 10:17:02 EDT
Both patches look good.
Comment 9 Artem Tikhomirov CLA 2008-06-05 10:22:16 EDT
(In reply to comment #4)
> ... as we'll need a corresponding bug/approval.

Rich, did you mean we need a separate bug with the fix or I can just attach a
patch here and save a 2 pmc/2 committers votes step?
Comment 10 Richard Gronback CLA 2008-06-05 10:28:29 EDT
(In reply to comment #9)
> (In reply to comment #4)
> > ... as we'll need a corresponding bug/approval.
> 
> Rich, did you mean we need a separate bug with the fix or I can just attach a
> patch here and save a 2 pmc/2 committers votes step?

I'm fine with following Christian's lead and attaching here, seeing as it's just a 2 line deletion per editor.

Comment 11 Artem Tikhomirov CLA 2008-06-05 10:37:51 EDT
Created attachment 103742 [details]
Fix for GMF Editors

(In reply to comment #10)
Yep, 2 lines per editor, 4 editors, 8 lines total gone.
Comment 12 Ed Merks CLA 2008-06-05 11:55:22 EDT
Note everyone that adding attachments kills prior approvals. :-(   So all your approvals need to be reinstated...
Comment 13 Ed Merks CLA 2008-06-05 11:57:23 EDT
The EMF changes are committed to CVS.
Comment 14 Christian Damus CLA 2008-06-05 14:19:39 EDT
(In reply to comment #12)
> Note everyone that adding attachments kills prior approvals. :-(   So all your
> approvals need to be reinstated...
> 

Oops!  I've just released my fix for EMF Transaction component.  I'll assume that it's still approved.
Comment 15 Ed Merks CLA 2008-06-05 14:33:23 EDT
Apparently all the +'s are back. :-)
Comment 16 Ed Willink CLA 2008-06-09 04:14:06 EDT
My UMLX editors needed another 7 fixes.

My contributions to QVT Declarative and QVT OML need another 6.

While checking my editors, I noticed that one of my editors still had

if (delta.getFlags() != IResourceDelta.MARKERS &&
   delta.getResource().getType() == IResource.FILE) {
   if ((delta.getKind() & (IResourceDelta.CHANGED | IResourceDelta.REMOVED)) != 0) {

but the others have the more modern

if (delta.getResource().getType() == IResource.FILE) {
   if (delta.getKind() == IResourceDelta.REMOVED ||
	delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) {

which ensures that editors close on delete.

There appears to be a significant problem with propagating generated editor fixes.

I suggest that EMF publish as a constant the current genmodel template version, and that generated editor validate this against the template version that produced them. A suppressable Error Log entry would then detect existence of obsolete editors.


Comment 17 Ed Merks CLA 2008-06-09 06:45:21 EDT
Invoking general all once per release is something uses should expect to do.  If they don't consider that, they probably won't be looking at stamps either.
Comment 18 Nick Boldt CLA 2008-06-09 15:23:13 EDT
Fix available in HEAD: 2.4.0RC4 (S200806091234).
Comment 19 Christian Damus CLA 2008-06-09 20:42:07 EDT
Fix available in HEAD: 1.2.0RC4 (S200806091902).