1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Bug 436892 - Standalone Debugger should not delete launch while it is still running

- distinguish between specifying an executable on command line or from the
  New Executable Dialog
- remove all launch configurations for the Executables project before
  deleting the project
- tell the configurer to not save and restore
- perform super.postWindowClose() after we have saved workspace

Change-Id: I1f02f3e033e5abf6c3c90a096312de2f134f7d8c
Reviewed-on: https://git.eclipse.org/r/28175
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
Tested-by: Jeff Johnston <jjohnstn@redhat.com>
(cherry picked from commit 0e6641c128)
Reviewed-on: https://git.eclipse.org/r/28206
This commit is contained in:
Jeff Johnston 2014-06-07 15:34:29 -04:00
parent 19e643f373
commit 45a165b37d
4 changed files with 28 additions and 9 deletions

View file

@ -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);

View file

@ -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() {

View file

@ -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<Executable> 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);
// 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");

View file

@ -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();