Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2015-06-22 14:16:02 +0000
committerAnton Leherbauer2015-06-22 14:16:20 +0000
commita41167ce295e27ce9761b1c5cfa4d87164a98a15 (patch)
treeb34fc1e93b89e67d6587c966089e328a4689c19c
parent0f36150dc23095a093f606588c8623af60d78749 (diff)
downloadorg.eclipse.tcf-a41167ce295e27ce9761b1c5cfa4d87164a98a15.tar.gz
org.eclipse.tcf-a41167ce295e27ce9761b1c5cfa4d87164a98a15.tar.xz
org.eclipse.tcf-a41167ce295e27ce9761b1c5cfa4d87164a98a15.zip
Target Explorer: Fix race condition on first debug launch
The TCF launch requires org.eclipse.tcf.debug.ui to be active when creating it, otherwise the debug model is not properly initialized.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/LaunchConfigurationDelegate.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/LaunchConfigurationDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/LaunchConfigurationDelegate.java
index 367dc569f..44b51ee72 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/LaunchConfigurationDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/delegates/LaunchConfigurationDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2012, 2015 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -11,11 +11,13 @@ package org.eclipse.tcf.te.tcf.launch.core.delegates;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
import org.eclipse.tcf.util.TCFTask;
+import org.osgi.framework.Bundle;
/**
* Default tcf launch configuration delegate implementation.
@@ -36,6 +38,9 @@ import org.eclipse.tcf.util.TCFTask;
*/
public class LaunchConfigurationDelegate extends org.eclipse.tcf.te.launch.core.delegates.LaunchConfigurationDelegate {
+ static Boolean is_headless;
+ static boolean ui_activation_done;
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.launch.core.delegates.LaunchConfigurationDelegate#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
*/
@@ -45,6 +50,23 @@ public class LaunchConfigurationDelegate extends org.eclipse.tcf.te.launch.core.
int cnt;
@Override
public void run() {
+ // see also TCFLaunchDelegate.getLaunch()
+ if (is_headless == null) {
+ Bundle b = Platform.getBundle("org.eclipse.ui.workbench"); //$NON-NLS-1$
+ is_headless = new Boolean(b == null || b.getState() != Bundle.ACTIVE);
+ }
+
+ if (!Boolean.TRUE.equals(is_headless) && !ui_activation_done) {
+ /* Make sure UI bundle is activated and is listening for launch events */
+ try {
+ Bundle bundle = Platform.getBundle("org.eclipse.tcf.debug.ui"); //$NON-NLS-1$
+ bundle.start(Bundle.START_TRANSIENT);
+ }
+ catch (Throwable x) {
+ Protocol.log("TCF debugger UI startup error", x); //$NON-NLS-1$
+ }
+ ui_activation_done = true;
+ }
// Need to delay at least one dispatch cycle to work around
// a possible racing between thread that calls getLaunch() and
// the process of activation of other TCF plug-ins.
@@ -64,10 +86,10 @@ public class LaunchConfigurationDelegate extends org.eclipse.tcf.te.launch.core.
@Override
protected void onLaunchFinished(ILaunch launch, IStatus status) {
super.onLaunchFinished(launch, status);
- if (launch instanceof Launch) {
- if (((Launch)launch).getCallback() != null) {
- ((Launch)launch).getCallback().done(launch, status);
- }
- }
+ if (launch instanceof Launch) {
+ if (((Launch)launch).getCallback() != null) {
+ ((Launch)launch).getCallback().done(launch, status);
+ }
+ }
}
}

Back to the top