1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 08:46:02 +02:00

Bug 312997: Set the default launch delegate using the launch configuration type instead of individual launch configurations. This avoids having the tabs for all launch delegates be created every time, and causing race conditions.

This commit is contained in:
Marc Khouzam 2010-05-19 15:43:16 +00:00
parent 2211e870c6
commit 06f8d01d6c
3 changed files with 69 additions and 50 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2007 QNX Software Systems and others.
* Copyright (c) 2004, 2010 QNX Software Systems 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
@ -41,6 +41,10 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchManager;
import org.osgi.framework.BundleContext;
/**
@ -338,6 +342,7 @@ public class CDebugCorePlugin extends Plugin {
createBreakpointListenersList();
createDisassemblyContextService();
setSessionManager( new SessionManager() );
setDefaultLaunchDelegates();
}
/* (non-Javadoc)
@ -429,4 +434,67 @@ public class CDebugCorePlugin extends Plugin {
if ( fDisassemblyContextService != null )
fDisassemblyContextService.dispose();
}
private void setDefaultLaunchDelegates() {
// Set the default launch delegates as early as possible, and do it only once (Bug 312997)
ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
HashSet<String> debugSet = new HashSet<String>();
debugSet.add(ILaunchManager.DEBUG_MODE);
ILaunchConfigurationType localCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
try {
if (localCfg.getPreferredDelegate(debugSet) == null) {
ILaunchDelegate[] delegates = localCfg.getDelegates(debugSet);
for (ILaunchDelegate delegate : delegates) {
if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE.equals(delegate.getId())) {
localCfg.setPreferredDelegate(debugSet, delegate);
break;
}
}
}
} catch (CoreException e) {}
ILaunchConfigurationType attachCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH);
try {
if (attachCfg.getPreferredDelegate(debugSet) == null) {
ILaunchDelegate[] delegates = attachCfg.getDelegates(debugSet);
for (ILaunchDelegate delegate : delegates) {
if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE.equals(delegate.getId())) {
attachCfg.setPreferredDelegate(debugSet, delegate);
break;
}
}
}
} catch (CoreException e) {}
ILaunchConfigurationType postMortemCfg = launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM);
try {
if (postMortemCfg.getPreferredDelegate(debugSet) == null) {
ILaunchDelegate[] delegates = postMortemCfg.getDelegates(debugSet);
for (ILaunchDelegate delegate : delegates) {
if (ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE.equals(delegate.getId())) {
postMortemCfg.setPreferredDelegate(debugSet, delegate);
break;
}
}
}
} catch (CoreException e) {}
HashSet<String> runSet = new HashSet<String>();
runSet.add(ILaunchManager.RUN_MODE);
try {
if (localCfg.getPreferredDelegate(runSet) == null) {
ILaunchDelegate[] delegates = localCfg.getDelegates(runSet);
for (ILaunchDelegate delegate : delegates) {
if (ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE.equals(delegate.getId())) {
localCfg.setPreferredDelegate(runSet, delegate);
break;
}
}
}
} catch (CoreException e) {}
}
}

View file

@ -15,7 +15,6 @@ package org.eclipse.cdt.debug.internal.ui.launch;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -202,26 +201,6 @@ public class CApplicationLaunchShortcut implements ILaunchShortcut2 {
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
// Workaround for bug 262840
try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.RUN_MODE);
if (wc.getPreferredDelegate(set) == null && wc.getType().getPreferredDelegate(set) == null) {
wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE);
}
} catch (CoreException e) {}
// We must also set the debug mode delegate because this configuration can be re-used
// in Debug mode.
try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.DEBUG_MODE);
if (wc.getPreferredDelegate(set) == null && wc.getType().getPreferredDelegate(set) == null) {
wc.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE);
}
} catch (CoreException e) {}
// End workaround for bug 262840
ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(bin.getCProject().getProject());
if (projDes != null)
{

View file

@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.launch.ui;
import java.util.HashSet;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
@ -34,7 +32,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@ -533,31 +530,6 @@ public class CMainTab extends CAbstractMainTab {
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
// Workaround for bug 262840
try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.DEBUG_MODE);
if ( config.getPreferredDelegate(set) == null && config.getType().getPreferredDelegate(set) == null) {
if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP)) {
config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_LOCAL_LAUNCH_DELEGATE);
} else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_ATTACH)) {
config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_ATTACH_LAUNCH_DELEGATE);
} else if (config.getType().getIdentifier().equals(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_POST_MORTEM)) {
config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_DEBUG_POSTMORTEM_LAUNCH_DELEGATE);
}
}
} catch (CoreException e) {}
// We must also set the preferred delegate for Run mode, because this configuration
// can be used in Run mode.
try {
HashSet<String> set = new HashSet<String>();
set.add(ILaunchManager.RUN_MODE);
if ( config.getPreferredDelegate(set) == null && config.getType().getPreferredDelegate(set) == null) {
config.setPreferredLaunchDelegate(set, ICDTLaunchConfigurationConstants.PREFERRED_RUN_LAUNCH_DELEGATE);
}
} catch (CoreException e) {}
// We set empty attributes for project & program so that when one config
// is
// compared to another, the existence of empty attributes doesn't cause