diff options
author | jonas | 2013-08-09 13:10:31 +0000 |
---|---|---|
committer | jonas | 2013-08-09 13:14:52 +0000 |
commit | 675fa2c2806fa0911257e2ef29422a7ac08708ed (patch) | |
tree | c9f7c5d83215d70f2c71b4c234d2284785ebad12 | |
parent | 3713e8310499a3ddabb9e5bfbe969880a21774f1 (diff) | |
download | org.eclipse.e4.tools-675fa2c2806fa0911257e2ef29422a7ac08708ed.tar.gz org.eclipse.e4.tools-675fa2c2806fa0911257e2ef29422a7ac08708ed.tar.xz org.eclipse.e4.tools-675fa2c2806fa0911257e2ef29422a7ac08708ed.zip |
Bug 414750 - DIViewPart does not handle the @PreDestroy correctly
3 files changed, 25 insertions, 4 deletions
diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/PartHelper.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/PartHelper.java index cbe2d201..2bc16f47 100644 --- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/PartHelper.java +++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/PartHelper.java @@ -107,4 +107,16 @@ public class PartHelper { listeners.add(listener); } } + + public static void disposeContextIfE3(IEclipseContext parentContext, + IEclipseContext context) { + // Check if running in 3.x, otherwise there was no dedicated context + // created + if (parentContext + .get("org.eclipse.e4.ui.workbench.IPresentationEngine") == null) { + context.dispose(); + context = null; + } + + } } diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java index c20e9225..f5ea188d 100644 --- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java +++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java @@ -148,8 +148,12 @@ public abstract class DIEditorPart<C> extends EditorPart implements @Override public void dispose() { - IEclipseContext parentContext = (IEclipseContext) getSite().getService( - IEclipseContext.class); + disposeContextIfE3((IEclipseContext) getSite().getService( + IEclipseContext.class), context); + super.dispose(); + } + + public static void disposeContextIfE3(IEclipseContext parentContext, IEclipseContext context) { // Check if running in 3.x, otherwise there was no dedicated context // created if (parentContext @@ -157,6 +161,5 @@ public abstract class DIEditorPart<C> extends EditorPart implements context.dispose(); context = null; } - super.dispose(); } } diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIViewPart.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIViewPart.java index 0a060eef..edabb810 100644 --- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIViewPart.java +++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIViewPart.java @@ -12,7 +12,6 @@ package org.eclipse.e4.tools.compat.parts; import org.eclipse.e4.core.contexts.ContextInjectionFactory; import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.di.InjectionException; import org.eclipse.e4.tools.compat.internal.PartHelper; import org.eclipse.e4.ui.di.Focus; import org.eclipse.swt.widgets.Composite; @@ -57,4 +56,11 @@ public abstract class DIViewPart<C> extends ViewPart { public void setFocus() { ContextInjectionFactory.invoke(component, Focus.class, context); } + + @Override + public void dispose() { + PartHelper.disposeContextIfE3((IEclipseContext) getSite().getService( + IEclipseContext.class), context); + super.dispose(); + } }
\ No newline at end of file |