diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java index 78c8b83221f..47bcf175f6c 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.application; +import org.eclipse.ui.application.IWorkbenchConfigurer; import org.eclipse.ui.application.IWorkbenchWindowConfigurer; import org.eclipse.ui.application.WorkbenchAdvisor; import org.eclipse.ui.application.WorkbenchWindowAdvisor; @@ -18,6 +19,13 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { private static final String PERSPECTIVE_ID = "org.eclipse.debug.ui.DebugPerspective"; //$NON-NLS-1$ + @Override + public void initialize(IWorkbenchConfigurer configurer) { + // TODO Auto-generated method stub + super.initialize(configurer); + configurer.setSaveAndRestore(false); + } + @Override public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { return new ApplicationWorkbenchWindowAdvisor(configurer); diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java index 110f7833ec7..13b4a135c81 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java @@ -251,7 +251,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { } else if (corefile != null && corefile.length() > 0) { config = DebugCoreFile.createLaunchConfig(monitor, buildLog, executable, corefile); } else if (executable != null && executable.length() > 0) { - config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments); + config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, true); } else { // No executable specified, look for last launch // and offer that to the end-user. @@ -308,7 +308,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { // the executable, we need to create a new configuration // and remove artifacts from the old one. if (config == null || !executable.equals(oldExecutable)) - config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments); + config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, true); ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION, buildLog); @@ -379,9 +379,9 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { @Override public void postWindowClose() { - super.postWindowClose(); if (ResourcesPlugin.getWorkspace() != null) disconnectFromWorkspace(); + super.postWindowClose(); } private void disconnectFromWorkspace() { diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java index 140057a9307..58f248985d2 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java @@ -57,7 +57,6 @@ public class DebugExecutable { private static final String GCC_BUILD_OPTIONS_PROVIDER_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$ private static final String STANDALONE_QUALIFIER = "org.eclipse.cdt.debug.application"; //$NON-NLS-1$ private static final String LAST_LAUNCH = "lastLaunch"; //$NON-NLS-1$ - public DebugExecutable() { } @@ -65,6 +64,7 @@ public class DebugExecutable { return DebugPlugin.getDefault().getLaunchManager(); } + /** * Import given executable into the Executables project then create a launch configuration. * @@ -76,7 +76,7 @@ public class DebugExecutable { * @throws InterruptedException */ public static ILaunchConfiguration importAndCreateLaunchConfig(IProgressMonitor monitor, - String executable, String buildLog, String arguments) + String executable, String buildLog, String arguments, boolean startup) throws CoreException, InterruptedException { ILaunchConfiguration config = null; File executableFile = new File(executable); @@ -84,7 +84,7 @@ public class DebugExecutable { ICProject cProject = CoreModel.getDefault().getCModel() .getCProject(defaultProjectName); // if a valid executable is specified, remove any executables already loaded in workspace - if (cProject.exists() && executableFile.exists()) { + if (startup && cProject.exists() && executableFile.exists()) { monitor.subTask(Messages.RemoveOldExecutable); IProject proj = cProject.getProject(); Collection elist = ExecutablesManager.getExecutablesManager().getExecutablesForProject(proj); @@ -112,6 +112,14 @@ public class DebugExecutable { // do nothing } } + + // Delete all launch configurations that specify the project we are about to delete + ILaunchConfiguration lconfigs[] = getLaunchManager().getLaunchConfigurations(); + for (ILaunchConfiguration lconfig : lconfigs) { + if (lconfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(proj.getName())) + lconfig.delete(); + } + // Delete project because we have deleted .cproject and settings files // by this point so just create a new Executables C project to use for // importing the new executable. @@ -260,8 +268,11 @@ public class DebugExecutable { } // System.out.println("about to create launch configuration"); config = createConfiguration(executable, arguments, buildLog, true); - String memento = config.getMemento(); - ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento); + // If we are starting up the debugger, save the executable as the default executable to use + if (startup) { + String memento = config.getMemento(); + ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento); + } monitor.worked(1); } else { System.out.println("Import job failed"); diff --git a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java index d4917fde43b..32db48fbc65 100644 --- a/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java +++ b/debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java @@ -48,7 +48,7 @@ public class DebugNewExecutableHandler extends AbstractHandler { String buildLog = info.getBuildLog(); try { - final ILaunchConfiguration config = DebugExecutable.importAndCreateLaunchConfig(new NullProgressMonitor(), executable, buildLog, arguments); + final ILaunchConfiguration config = DebugExecutable.importAndCreateLaunchConfig(new NullProgressMonitor(), executable, buildLog, arguments, false); if (config != null) { // System.out.println("about to add job change listener"); final JobContainer LaunchJobs = new JobContainer();