Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 229022 - [Progress] Display#getShells returns disposed shell
Summary: [Progress] Display#getShells returns disposed shell
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 229021 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-04-28 04:48 EDT by Benno Baumgartner CLA
Modified: 2018-07-26 10:37 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2008-04-28 04:48:32 EDT
I20080427-2000

To reproduce the latest I-Build I20080427-2000 is required! This is on WinXP.

1. Open a CU in Java Editor
2. Enable breadcrumb (toolbar button)
3. Left click on a package in the breadcrumb
4. Press Alt-Shift-R (rename)
Is:
org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:3773)
	at org.eclipse.swt.SWT.error(SWT.java:3691)
	at org.eclipse.swt.SWT.error(SWT.java:3662)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:462)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:335)
	at org.eclipse.swt.widgets.Shell.setEnabled(Shell.java:1404)
	at org.eclipse.ui.internal.progress.ProgressManager.setUserInterfaceActive(ProgressManager.java:1317)
	at org.eclipse.ui.internal.progress.ProgressManager.access$4(ProgressManager.java:1312)
	at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:983)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:1012)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:987)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.checkInitialConditions(RefactoringWizardOpenOperation.java:168)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.access$0(RefactoringWizardOpenOperation.java:164)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:127)
	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.ui.refactoring.UserInterfaceStarter.activate(UserInterfaceStarter.java:60)
	at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameUserInterfaceStarter.activate(RenameUserInterfaceStarter.java:31)
	at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:160)
	at org.eclipse.jdt.ui.refactoring.RenameSupport.openDialog(RenameSupport.java:117)
	at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startRenameRefactoring(RefactoringExecutionStarter.java:436)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:194)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:106)
	at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:108)
	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.commands.ActionHandler.execute(ActionHandler.java:119)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:471)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:822)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:511)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1161)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1001)
	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.Control.traverse(Control.java:3493)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:3337)
	at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:1064)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:3355)
	at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:4297)
	at org.eclipse.swt.widgets.Display.filterMessage(Display.java:1175)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3375)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2351)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2315)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2181)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:477)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:472)
	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:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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)

 
The failing code is:
                Shell[] shells = workbench.getDisplay().getShells();
		if (active) {
			for (int i = 0; i < shells.length; i++) {
				shells[i].setEnabled(active);
			}
		} else {
....

But getShells() is spec'd as:
 * .......all shells which have
 * not been disposed......

This is a major bug for us, it makes us look bad.
Comment 1 Dani Megert CLA 2008-04-28 04:50:51 EDT
We either need a fix for M7 or add a guard to ProgressManager.setUserInterfaceActive(...).
Comment 2 Grant Gayed CLA 2008-04-28 11:21:25 EDT
*** Bug 229021 has been marked as a duplicate of this bug. ***
Comment 3 Grant Gayed CLA 2008-04-28 12:25:30 EDT
will look at this with SN
Comment 4 Grant Gayed CLA 2008-04-28 13:01:50 EDT
We've investigated this, it's not an swt problem.  Display.getShells() answers all non-disposed Shells in this scenario, but 1+ of them becomes disposed by a listener while the list is being held in ProgressManager.setUserInterfaceActive(boolean).  If you change this method to the snippet below (some println's added) you'll see that initially none of the shells are disposed but one of them becomes disposed as a result of the shells[i].setEnabled(active) line.  Moving to UI.

private void setUserInterfaceActive(boolean active) {
	System.out.println("setUserInterfaceActive called");
	IWorkbench workbench = PlatformUI.getWorkbench();
	Shell[] shells = workbench.getDisplay().getShells();
	for (int i = 0; i < shells.length; i++) {
		if (shells[i].isDisposed()) {
			System.out.println("Shell disposed in original list!");
		}
	}
		
	if (active) {
		for (int i = 0; i < shells.length; i++) {
			if (shells[i].isDisposed()) {
				System.out.println("shell disposed later on by application code");
			}
			shells[i].setEnabled(active);
		}
	} else {
		// Deactive shells in reverse order
		for (int i = shells.length - 1; i >= 0; i--) {
			shells[i].setEnabled(active);
		}
	}
}
Comment 5 Dani Megert CLA 2008-04-29 01:54:05 EDT
OK. I'll protect the code against that.
Comment 6 Dani Megert CLA 2008-04-29 03:10:26 EDT
Fixed in HEAD.
Will be picked up by next Platform UI contribution for M7.
Comment 7 Dani Megert CLA 2008-04-29 03:12:48 EDT
.
Comment 8 Dani Megert CLA 2008-04-30 03:51:55 EDT
Verified in I20080430-0100.