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

Bug 341271

Summary: UIMonitorUtility is not equipped to handle applications with more than one shell
Product: [Technology] Subversive Reporter: Dan O'Connor <dan_o'connor>
Component: UIAssignee: Igor Burilo <igor.burilo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dan_o'connor
Version: unspecifiedKeywords: ui
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Dan O'Connor CLA 2011-03-29 14:34:50 EDT
Build Identifier: M20110210-1200

The product I am working on allows more than one workbench window to be opened at the same time. As a result during a sync operation the focus can be switched to the wrong workbench window inadvertently. The issue (or at least part of it) is because org.eclipse.team.svn.ui.utility.UIMonitorUtility does not check if the shell it is returning is the active shell:

org.eclipse.team.svn.ui.utility.UIMonitorUtility.java

public static Shell getShell() {
		Display display = UIMonitorUtility.getDisplay();
		// NEVER ! use the active shell because it could be disposed asynchronously by external thread
		for (Shell shell : display.getShells()) {
			if (shell.getParent() == null) {
				return shell;
			}
		}
		return new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
	}

This can easily return the wrong shell, and causes the wrong workbench window to be activated!

Reproducible: Always
Comment 1 Alexander Gurov CLA 2011-03-31 15:15:15 EDT
The method was reworked and its usage were enforced within the plug-in source code.