diff options
author | eutarass | 2009-04-13 18:00:32 +0000 |
---|---|---|
committer | eutarass | 2009-04-13 18:00:32 +0000 |
commit | 9589911df34adc93433ac83af96e5bcc9f9d89b6 (patch) | |
tree | e74c2e8751baabe66dfeaa2acf6234b211fb536d /plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug | |
parent | 44babd128cf9813ab42cf32dea66a7beadb94e8e (diff) | |
download | org.eclipse.tcf-9589911df34adc93433ac83af96e5bcc9f9d89b6.tar.gz org.eclipse.tcf-9589911df34adc93433ac83af96e5bcc9f9d89b6.tar.xz org.eclipse.tcf-9589911df34adc93433ac83af96e5bcc9f9d89b6.zip |
TCF Debugger: fixed a racing condition during initialization.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug')
2 files changed, 17 insertions, 3 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java index 431550b6b..14a52e379 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFLaunchDelegate.java @@ -18,6 +18,7 @@ import org.eclipse.debug.core.model.LaunchConfigurationDelegate; import org.eclipse.tm.internal.tcf.debug.model.ITCFConstants; import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch; import org.eclipse.tm.tcf.protocol.Protocol; +import org.eclipse.tm.tcf.util.TCFTask; public class TCFLaunchDelegate extends LaunchConfigurationDelegate { @@ -32,8 +33,17 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate { ATTR_WORKING_DIRECTORY = ITCFConstants.ID_TCF_DEBUG_MODEL + ".WorkingDirectory", ATTR_USE_TERMINAL = ITCFConstants.ID_TCF_DEBUG_MODEL + ".UseTerminal"; - public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException { - return new TCFLaunch(configuration, mode); + public ILaunch getLaunch(final ILaunchConfiguration configuration, final String mode) throws CoreException { + return new TCFTask<ILaunch>() { + int cnt; + public void run() { + // 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. + if (cnt++ < 2) Protocol.invokeLater(this); + else done(new TCFLaunch(configuration, mode)); + } + }.getE(); } public void launch(final ILaunchConfiguration configuration, final String mode, diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java index 0c0f94325..9190c1de2 100644 --- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java +++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFLaunch.java @@ -52,6 +52,8 @@ import org.eclipse.tm.tcf.services.IProcesses.ProcessContext; public class TCFLaunch extends Launch { public interface Listener { + + public void onCreated(TCFLaunch launch); public void onConnected(TCFLaunch launch); @@ -100,6 +102,7 @@ public class TCFLaunch extends Launch { public TCFLaunch(ILaunchConfiguration launchConfiguration, String mode) { super(launchConfiguration, mode, null); + for (Listener l : listeners) l.onCreated(TCFLaunch.this); } private void onConnected() { @@ -118,7 +121,7 @@ public class TCFLaunch extends Launch { for (Iterator<Listener> i = listeners.iterator(); i.hasNext();) { i.next().onDisconnected(this); } - fireChanged(); + if (DebugPlugin.getDefault() != null) fireChanged(); runShutdownSequence(new Runnable() { public void run() { shutdown = true; @@ -429,6 +432,7 @@ public class TCFLaunch extends Launch { } private void disconnectStream(String id) { + if (channel.getState() != IChannel.STATE_OPEN) return; IStreams streams = getService(IStreams.class); streams.disconnect(id, new IStreams.DoneDisconnect() { public void doneDisconnect(IToken token, Exception error) { |