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:
parent
19e643f373
commit
45a165b37d
4 changed files with 28 additions and 9 deletions
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.application;
|
package org.eclipse.cdt.debug.application;
|
||||||
|
|
||||||
|
import org.eclipse.ui.application.IWorkbenchConfigurer;
|
||||||
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
|
||||||
import org.eclipse.ui.application.WorkbenchAdvisor;
|
import org.eclipse.ui.application.WorkbenchAdvisor;
|
||||||
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
|
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$
|
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
|
@Override
|
||||||
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
|
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
|
||||||
return new ApplicationWorkbenchWindowAdvisor(configurer);
|
return new ApplicationWorkbenchWindowAdvisor(configurer);
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||||
} else if (corefile != null && corefile.length() > 0) {
|
} else if (corefile != null && corefile.length() > 0) {
|
||||||
config = DebugCoreFile.createLaunchConfig(monitor, buildLog, executable, corefile);
|
config = DebugCoreFile.createLaunchConfig(monitor, buildLog, executable, corefile);
|
||||||
} else if (executable != null && executable.length() > 0) {
|
} else if (executable != null && executable.length() > 0) {
|
||||||
config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments);
|
config = DebugExecutable.importAndCreateLaunchConfig(monitor, executable, buildLog, arguments, true);
|
||||||
} else {
|
} else {
|
||||||
// No executable specified, look for last launch
|
// No executable specified, look for last launch
|
||||||
// and offer that to the end-user.
|
// 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
|
// the executable, we need to create a new configuration
|
||||||
// and remove artifacts from the old one.
|
// and remove artifacts from the old one.
|
||||||
if (config == null || !executable.equals(oldExecutable))
|
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();
|
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
|
||||||
wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION,
|
wc.setAttribute(ICDTStandaloneDebugLaunchConstants.BUILD_LOG_LOCATION,
|
||||||
buildLog);
|
buildLog);
|
||||||
|
@ -379,9 +379,9 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postWindowClose() {
|
public void postWindowClose() {
|
||||||
super.postWindowClose();
|
|
||||||
if (ResourcesPlugin.getWorkspace() != null)
|
if (ResourcesPlugin.getWorkspace() != null)
|
||||||
disconnectFromWorkspace();
|
disconnectFromWorkspace();
|
||||||
|
super.postWindowClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disconnectFromWorkspace() {
|
private void disconnectFromWorkspace() {
|
||||||
|
|
|
@ -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 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 STANDALONE_QUALIFIER = "org.eclipse.cdt.debug.application"; //$NON-NLS-1$
|
||||||
private static final String LAST_LAUNCH = "lastLaunch"; //$NON-NLS-1$
|
private static final String LAST_LAUNCH = "lastLaunch"; //$NON-NLS-1$
|
||||||
|
|
||||||
public DebugExecutable() {
|
public DebugExecutable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +64,7 @@ public class DebugExecutable {
|
||||||
return DebugPlugin.getDefault().getLaunchManager();
|
return DebugPlugin.getDefault().getLaunchManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import given executable into the Executables project then create a launch configuration.
|
* Import given executable into the Executables project then create a launch configuration.
|
||||||
*
|
*
|
||||||
|
@ -76,7 +76,7 @@ public class DebugExecutable {
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public static ILaunchConfiguration importAndCreateLaunchConfig(IProgressMonitor monitor,
|
public static ILaunchConfiguration importAndCreateLaunchConfig(IProgressMonitor monitor,
|
||||||
String executable, String buildLog, String arguments)
|
String executable, String buildLog, String arguments, boolean startup)
|
||||||
throws CoreException, InterruptedException {
|
throws CoreException, InterruptedException {
|
||||||
ILaunchConfiguration config = null;
|
ILaunchConfiguration config = null;
|
||||||
File executableFile = new File(executable);
|
File executableFile = new File(executable);
|
||||||
|
@ -84,7 +84,7 @@ public class DebugExecutable {
|
||||||
ICProject cProject = CoreModel.getDefault().getCModel()
|
ICProject cProject = CoreModel.getDefault().getCModel()
|
||||||
.getCProject(defaultProjectName);
|
.getCProject(defaultProjectName);
|
||||||
// if a valid executable is specified, remove any executables already loaded in workspace
|
// 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);
|
monitor.subTask(Messages.RemoveOldExecutable);
|
||||||
IProject proj = cProject.getProject();
|
IProject proj = cProject.getProject();
|
||||||
Collection<Executable> elist = ExecutablesManager.getExecutablesManager().getExecutablesForProject(proj);
|
Collection<Executable> elist = ExecutablesManager.getExecutablesManager().getExecutablesForProject(proj);
|
||||||
|
@ -112,6 +112,14 @@ public class DebugExecutable {
|
||||||
// do nothing
|
// 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
|
// Delete project because we have deleted .cproject and settings files
|
||||||
// by this point so just create a new Executables C project to use for
|
// by this point so just create a new Executables C project to use for
|
||||||
// importing the new executable.
|
// importing the new executable.
|
||||||
|
@ -260,8 +268,11 @@ public class DebugExecutable {
|
||||||
}
|
}
|
||||||
// System.out.println("about to create launch configuration");
|
// System.out.println("about to create launch configuration");
|
||||||
config = createConfiguration(executable, arguments, buildLog, true);
|
config = createConfiguration(executable, arguments, buildLog, true);
|
||||||
String memento = config.getMemento();
|
// If we are starting up the debugger, save the executable as the default executable to use
|
||||||
ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento);
|
if (startup) {
|
||||||
|
String memento = config.getMemento();
|
||||||
|
ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(new QualifiedName(STANDALONE_QUALIFIER, LAST_LAUNCH), memento);
|
||||||
|
}
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Import job failed");
|
System.out.println("Import job failed");
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class DebugNewExecutableHandler extends AbstractHandler {
|
||||||
String buildLog = info.getBuildLog();
|
String buildLog = info.getBuildLog();
|
||||||
|
|
||||||
try {
|
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) {
|
if (config != null) {
|
||||||
// System.out.println("about to add job change listener");
|
// System.out.println("about to add job change listener");
|
||||||
final JobContainer LaunchJobs = new JobContainer();
|
final JobContainer LaunchJobs = new JobContainer();
|
||||||
|
|
Loading…
Add table
Reference in a new issue