Fix deadlock when the Select Connection dialog is up, user plugs in a device, and the Remote Connections view is shown RCL_2_4
authordadubrow
Thu, 11 Feb 2010 11:38:33 -0600
branchRCL_2_4
changeset 932 9eff68f52ec6
parent 931 c6f86d0867c2
child 933 62a61caee614
Fix deadlock when the Select Connection dialog is up, user plugs in a device, and the Remote Connections view is shown
debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java
--- a/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java	Thu Feb 11 11:31:22 2010 -0600
+++ b/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java	Thu Feb 11 11:38:33 2010 -0600
@@ -20,6 +20,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PartInitException;
 
 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
@@ -128,15 +130,28 @@
 	}
 
 	private void showConnectionsView() {
-		RunRunnableWhenWorkbenchVisibleJob.start(new Runnable() {
-			public void run() {
-				// try to show the connections view to start service testers
-				try {
-					WorkbenchUtils.getView(CONNECTIONS_VIEW_ID);
-				} catch (PartInitException e) {
+		// avoid deadlock if this called as a result of a launch sequence issuing a "select connection" dialog
+		Shell shell = WorkbenchUtils.getActiveShell();
+		if (shell == null || !shell.isVisible()) {
+			RunRunnableWhenWorkbenchVisibleJob.start(new Runnable() {
+				public void run() {
+					// try to show the connections view to start service testers
+					try {
+						WorkbenchUtils.getView(CONNECTIONS_VIEW_ID);
+					} catch (PartInitException e) {
+					}
 				}
-			}
-		});
+			});
+		} else {
+			Display.getDefault().asyncExec(new Runnable() {
+				public void run() {
+					try {
+						WorkbenchUtils.getView(CONNECTIONS_VIEW_ID);
+					} catch (PartInitException e) {
+					}
+				}
+			});
+		}
 	}
 	
 	private void reconcileAsCurrent(IConnection connection) {