diff options
author | Pawel Piech | 2012-04-27 05:07:11 +0000 |
---|---|---|
committer | Pawel Piech | 2012-04-27 05:07:11 +0000 |
commit | fae6ff74493e33acdb1cabc06338970ec76cf6df (patch) | |
tree | b0654ca6307f24dad863fc74c56878427d80a4e6 | |
parent | 0fa0cd45458ea9d1d82c0b8662ca98066cc57636 (diff) | |
download | eclipse.platform.debug-fae6ff74493e33acdb1cabc06338970ec76cf6df.tar.gz eclipse.platform.debug-fae6ff74493e33acdb1cabc06338970ec76cf6df.tar.xz eclipse.platform.debug-fae6ff74493e33acdb1cabc06338970ec76cf6df.zip |
Bug 377847 - [debug context] NPE when adding a debug context provider with IDebugContextProvider.getPart() == null.v20120427-0507I20120430-2000I20120430-1800I20120430-1500I20120430-1300I20120429-2000I20120429-1800I20120429-1245I20120429-1000I20120428-1230I20120428-0800I20120428-0140
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java index eac1598d2..08203cab3 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java @@ -73,11 +73,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis if (fWindow == null) return; // disposed IWorkbenchPart part = provider.getPart(); - String id = null; - if (part != null) { - id = getCombinedPartId(part); - } - fProvidersByPartId.put(id, provider); + fProvidersByPartId.put( getCombinedPartId(part), provider ); // Check if provider is a window context provider boolean canSetActive = true; @@ -107,12 +103,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis public synchronized void removeDebugContextProvider(IDebugContextProvider provider) { int index = fProviders.indexOf(provider); if (index >= 0) { - IWorkbenchPart part = provider.getPart(); - String id = null; - if (part != null) { - id = getCombinedPartId(part); - } - fProvidersByPartId.remove(id); + fProvidersByPartId.remove( getCombinedPartId(provider.getPart()) ); fProviders.remove(index); IDebugContextProvider activeProvider = getActiveProvider(); if (index == 0) { @@ -239,7 +230,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis outer: for (Iterator itr = fListenersByPartId.keySet().iterator(); itr.hasNext();) { String listenerPartId = (String)itr.next(); for (int i = 0; i < fProviders.size(); i++) { - String providerPartId = getCombinedPartId(((IDebugContextProvider)fProviders.get(i)).getPart()); + String providerPartId = getCombinedPartId(((IDebugContextProvider)fProviders.get(i)).getPart()); if ((listenerPartId == null && providerPartId == null) || (listenerPartId != null && listenerPartId.equals(providerPartId))) { @@ -274,7 +265,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis outer: for (Iterator itr = fPostListenersByPartId.keySet().iterator(); itr.hasNext();) { String listenerPartId = (String)itr.next(); for (int i = 0; i < fProviders.size(); i++) { - String providerPartId = getCombinedPartId(((IDebugContextProvider)fProviders.get(i)).getPart()); + String providerPartId = getCombinedPartId(((IDebugContextProvider)fProviders.get(i)).getPart()); if ((listenerPartId == null && providerPartId == null) || (listenerPartId != null && listenerPartId.equals(providerPartId))) { @@ -417,8 +408,10 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis notify(event); } - private String getCombinedPartId(IWorkbenchPart part) { - if (part.getSite() instanceof IViewSite) { + private String getCombinedPartId(IWorkbenchPart part) { + if (part == null) { + return null; + } else if (part.getSite() instanceof IViewSite) { IViewSite site = (IViewSite)part.getSite(); return getCombinedPartId(site.getId(), site.getSecondaryId()); |