Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2014-06-07 19:34:29 +0000
committerJeff Johnston2014-06-09 15:39:32 +0000
commit0e6641c128d93d4495edb1a6c3fa6f6c9517e51c (patch)
treec39be8293522bb2e72d127314ecb05fea7527ec0
parent9e72bd9258d37bbd71a0474634f449807922481f (diff)
downloadorg.eclipse.cdt-0e6641c128d93d4495edb1a6c3fa6f6c9517e51c.tar.gz
org.eclipse.cdt-0e6641c128d93d4495edb1a6c3fa6f6c9517e51c.tar.xz
org.eclipse.cdt-0e6641c128d93d4495edb1a6c3fa6f6c9517e51c.zip
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>
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchAdvisor.java8
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/debug/application/ApplicationWorkbenchWindowAdvisor.java6
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugExecutable.java21
-rw-r--r--debug/org.eclipse.cdt.debug.application/src/org/eclipse/cdt/internal/debug/application/DebugNewExecutableHandler.java2
4 files changed, 28 insertions, 9 deletions
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 0c94e45ea69..539c213310a 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
@@ -240,7 +240,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.
@@ -297,7 +297,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);
@@ -368,9 +368,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<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);
- 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();

Back to the top