1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 440015 - Fix NPE On Launch Configuration Edit

Prompt user with error dialog when they attempt to edit a launch
configuration with no active target selected.

Change-Id: I3b0a649312259beba73437223e5b96e99396d31e
Signed-off-by: Jonathan Williams <jonwilliams@qnx.com>
Reviewed-on: https://git.eclipse.org/r/30184
Tested-by: Hudson CI
Reviewed-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
Jonathan Williams 2014-07-21 10:03:15 -04:00 committed by Doug Schaefer
parent 0cdedcb9e9
commit 947b25009a
2 changed files with 7 additions and 2 deletions

View file

@ -430,7 +430,7 @@ public class LaunchBarManager extends PlatformObject implements ILaunchBarManage
@Override
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
if (activeLaunchDesc == null)
if (activeLaunchDesc == null || target == null)
return null;
Map<String, ILaunchConfigurationProvider> targetMap = configProviders.get(descriptor.getType().getId());

View file

@ -30,6 +30,7 @@ import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
@ -146,12 +147,16 @@ public class ConfigSelector extends CSelector {
@Override
public void handleEdit(Object element) {
try {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
ILaunchDescriptor desc = (ILaunchDescriptor) element;
ILaunchMode mode = getManager().getActiveLaunchMode();
ILaunchTarget target = getManager().getActiveLaunchTarget();
if (target == null) {
MessageDialog.openError(shell, "No Active Target", "You must create a target to edit this launch configuration.");
return;
}
ILaunchConfigurationType configType = getManager().getLaunchConfigurationType(desc, target);
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier());
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
if (groupExt != null) {
ILaunchConfiguration config = getManager().getLaunchConfiguration(desc, target);