From af395d867660ccd39b749dc6605a2ab96e46a325 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 31 Oct 2014 11:35:25 -0400 Subject: [PATCH] Bug 449479 - Fix Exceptions and LC cache corruption on LC delete Change-Id: Icd211eb1c9c34082208a709926b56affee6eac61 Signed-off-by: Jonathan Williams Reviewed-on: https://git.eclipse.org/r/35748 Reviewed-by: Doug Schaefer Tested-by: Doug Schaefer --- .../core/internal/LaunchBarManager.java | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java index 8afe127916d..dc6aa8eed64 100644 --- a/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java +++ b/launch/org.eclipse.cdt.launchbar.core/src/org/eclipse/cdt/launchbar/core/internal/LaunchBarManager.java @@ -1057,22 +1057,44 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchConfiguration @Override public void launchConfigurationRemoved(ILaunchConfiguration configuration) { Activator.trace("launch config removed " + configuration); - - try { - LaunchConfigProviderInfo info = configProviders.get(configuration.getType().getIdentifier()); - if (info != null) { - ILaunchConfigurationProvider provider = info.getProvider(); - if (provider.launchConfigurationRemoved(configuration)) { - Activator.trace("launch config removed by " + provider); - return; + + // Is there any way this method is called when a LC still exists??? This may be dead code. + // configuration.getType() will fail when !configuration.exists() + if (configuration.exists()) { + try { + LaunchConfigProviderInfo info = configProviders.get(configuration.getType().getIdentifier()); + if (info != null) { + ILaunchConfigurationProvider provider = info.getProvider(); + if (provider.launchConfigurationRemoved(configuration)) { + Activator.trace("launch config removed by " + provider); + return; + } } + } catch (CoreException e) { + Activator.log(e.getStatus()); } - } catch (CoreException e) { - Activator.log(e.getStatus()); } Activator.trace("launch config not claimed"); ILaunchDescriptor desc = objectDescriptorMap.get(configuration); + if (desc == null) { + /* WARNING: This is slow. Call only as a last resort */ + Iterator>> iter = configs.entrySet().iterator(); + while (iter.hasNext()) { + Entry> e1 = iter.next(); + if (e1.getValue().containsValue(configuration)) { + Iterator> iter2 = e1.getValue().entrySet().iterator(); + while (iter2.hasNext()) { + Entry e2 = iter2.next(); + if (e2.getValue().equals(configuration)) { + e1.getValue().remove((ILaunchConfigurationProvider) e2.getKey()); + return; + } + } + break; + } + } + } try { removeDescriptor(configuration, desc); } catch (CoreException e) {