diff options
author | Markus Duft | 2017-08-07 11:20:26 +0000 |
---|---|---|
committer | Markus Duft | 2017-08-07 11:21:32 +0000 |
commit | 8df4ce30969f1cca45747373252de64a5077c840 (patch) | |
tree | 48f1d690dcdc6bb0db84ccda0bee63cad3df9b78 | |
parent | 0bbc5012c2fd32f76a7cebebb0698d9e6ed1e0f8 (diff) | |
download | eclipse.platform.debug-8df4ce30969f1cca45747373252de64a5077c840.tar.gz eclipse.platform.debug-8df4ce30969f1cca45747373252de64a5077c840.tar.xz eclipse.platform.debug-8df4ce30969f1cca45747373252de64a5077c840.zip |
Bug 519684 - don't execute post launch actions when adopting
When adopting already existing launches, the group should not execute
that launches post launch action. Also notification about a launched
group element can/must be inhibited.
Change-Id: I3e162f376eb6a47a4580f4ddb20257962b33ed53
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
2 files changed, 20 insertions, 7 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java index fbd3397d4..c948c63b3 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java @@ -147,8 +147,10 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat private boolean launchChild(SubMonitor monitor, final GroupLaunch group, GroupLaunchElement le, final ILaunchConfiguration child, final String localMode, boolean lastConfig) throws CoreException { final Set<ILaunch> running = le.adoptIfRunning ? findRunningLaunch(le.name) : Collections.emptySet(); ILaunch subLaunch = running.stream().findFirst().orElse(null); + boolean launched = false; if (subLaunch == null) { subLaunch = child.launch(localMode, monitor); + launched = true; } group.addSubLaunch(subLaunch); @@ -159,11 +161,13 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat // So, fake another event now. group.launchChanged(subLaunch); - // give handler a chance to perform additional actions after - // launching each of the members. - IStatusHandler postLaunchHandler = DebugPlugin.getDefault().getStatusHandler(GROUP_ELEMENT_STARTED); - postLaunchHandler.handleStatus(GROUP_ELEMENT_STARTED, new ILaunch[] { - group, subLaunch }); + if (launched) { + // give handler a chance to perform additional actions after + // launching each of the members. + IStatusHandler postLaunchHandler = DebugPlugin.getDefault().getStatusHandler(GROUP_ELEMENT_STARTED); + postLaunchHandler.handleStatus(GROUP_ELEMENT_STARTED, new ILaunch[] { + group, subLaunch }); + } // if this is the last child, mark the group as "launching finished", so // that from now on the last terminating child will also terminate the @@ -172,7 +176,13 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat group.markLaunched(); } - return postLaunchAction(subLaunch, le, monitor); + // in case we adopted the launch, and did not launch outselves, don't + // execute the post launch action! + if (launched) { + return postLaunchAction(subLaunch, le, monitor); + } else { + return true; + } } private boolean postLaunchAction(ILaunch subLaunch, GroupLaunchElement le, IProgressMonitor monitor) { diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java index 8799b6f60..14ff10660 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java @@ -234,16 +234,19 @@ public class LaunchGroupTests extends AbstractLaunchTest { final ILaunchConfiguration grp = createLaunchGroup(DEF_GRP_NAME, createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, false)); final ILaunchConfiguration grp2 = createLaunchGroup("Group 2", createLaunchGroupElement(grp, GroupElementPostLaunchAction.NONE, null, false)); //$NON-NLS-1$ - final ILaunchConfiguration grp3 = createLaunchGroup("Group 3", createLaunchGroupElement(grp2, GroupElementPostLaunchAction.NONE, null, false), createLaunchGroupElement(t1, GroupElementPostLaunchAction.NONE, null, true)); //$NON-NLS-1$ + final ILaunchConfiguration grp3 = createLaunchGroup("Group 3", createLaunchGroupElement(grp2, GroupElementPostLaunchAction.NONE, null, false), createLaunchGroupElement(t1, GroupElementPostLaunchAction.DELAY, 10, true)); //$NON-NLS-1$ // attention: need to do this before launching! LaunchHistory runHistory = getRunLaunchHistory(); lcToCount = t1; getLaunchManager().addLaunchListener(lcListener); + + long startTime = System.currentTimeMillis(); grp3.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); ILaunchConfiguration[] history = runHistory.getHistory(); + assertTrue("post launch should not be run", (System.currentTimeMillis() - startTime) < 9_000); //$NON-NLS-1$ assertEquals(4, history.length); assertTrue("history[0] should be Group 3", history[0].contentsEqual(grp3)); //$NON-NLS-1$ assertTrue("history[1] should be Group 2", history[1].contentsEqual(grp2)); //$NON-NLS-1$ |