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

Bug 440272 - Autoselect Another Target If Active Target Is Removed

Set another target to the active target if there is one available. Set
activeTarget to null if the list is empty.

Also fixed an NPE if setActiveLaunchTarget() was called with null.

Change-Id: I79d0a9c8a6b6e93b403dfbdf0d8bf0c8ea441297
Signed-off-by: Jonathan Williams <jonwilliams@qnx.com>
Reviewed-on: https://git.eclipse.org/r/30386
Tested-by: Hudson CI
Reviewed-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
Jonathan Williams 2014-07-23 16:56:45 -04:00 committed by Doug Schaefer
parent bd792bc393
commit 30b00414b0

View file

@ -375,6 +375,13 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
public void setActiveLaunchTarget(ILaunchTarget target) {
if (activeLaunchTarget == target) return;
if (target == null) {
// try and select another target
ILaunchTarget[] targets = getLaunchTargets();
if (targets.length > 0) {
target = targets[0];
}
}
activeLaunchTarget = target;
for (Listener listener : listeners)
@ -385,6 +392,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
Preferences store = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).node(activeLaunchDesc.getName());
if (target != null) {
target.setActive();
store.put(PREF_ACTIVE_LAUNCH_TARGET, target.getId());
} else {
store.remove(PREF_ACTIVE_LAUNCH_TARGET);
@ -395,8 +403,6 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
// TODO log
e.printStackTrace();
}
target.setActive();
}
@Override