diff options
author | Maxime PORHEL | 2014-05-20 14:43:13 +0000 |
---|---|---|
committer | Maxime PORHEL | 2014-05-20 14:43:13 +0000 |
commit | 8ae09ebe84b2a3b774aba33554d7cf9c2c9f1cd3 (patch) | |
tree | fe6bfa7e14c54ebbbd74e3bd64642f02a21374d8 | |
parent | 5df8b58dd7472f89946c7803b3c17a42824c7ee7 (diff) | |
download | org.eclipse.sirius-1.0.0rc1.tar.gz org.eclipse.sirius-1.0.0rc1.tar.xz org.eclipse.sirius-1.0.0rc1.zip |
[cleanup] Avoid NPE during platform shutdownv1.0.0rc1
Change-Id: Idee97760ce975d69b4362f70a2263cb1b7bb7b07
Signed-off-by: Maxime PORHEL <maxime.porhel@obeo.fr>
-rw-r--r-- | plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarToolBarManager.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarToolBarManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarToolBarManager.java index ccd3408c1a..7edb2d4180 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarToolBarManager.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarToolBarManager.java @@ -26,6 +26,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; import org.eclipse.ui.forms.FormColors; @@ -81,17 +82,29 @@ public class TabbarToolBarManager extends ToolBarManager { @Override public void update(boolean force) { - IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - if (activePage != null && tabbarPart instanceof DDiagramEditor && activePage.getActivePart() != tabbarPart) { + IWorkbenchPage activePage = getSafeActivePage(); + if (activePage == null) { + // No active page -> return. + return; + } else if (tabbarPart instanceof DDiagramEditor && activePage.getActivePart() != tabbarPart) { if (getControl().getItems().length > 0) { // part is not focused -> return. return; } } + super.update(force); updateGradientBackground(); } + private IWorkbenchPage getSafeActivePage() { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (activeWorkbenchWindow != null) { + return activeWorkbenchWindow.getActivePage(); + } + return null; + } + /** * Update the gradient background if needed: * <UL> |