Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-11-15 15:59:32 +0000
committerChristian W. Damus2014-11-15 20:39:31 +0000
commitada357d5a5456444e73ff752c40e8e11583e12b3 (patch)
treeccb13b1af65602f9f896c8d804bf1648aab477b8 /plugins/infra
parente8ecf4753926f7755f7902e25690030ee1a36704 (diff)
downloadorg.eclipse.papyrus-ada357d5a5456444e73ff752c40e8e11583e12b3.tar.gz
org.eclipse.papyrus-ada357d5a5456444e73ff752c40e8e11583e12b3.tar.xz
org.eclipse.papyrus-ada357d5a5456444e73ff752c40e8e11583e12b3.zip
451683: Memory leak in stereotype repair
https://bugs.eclipse.org/bugs/show_bug.cgi?id=451683 Fix memory leaks in: - the common navigator framework (Model Explorer) - the Papyrus EMF Facet tree content provider (Model Explorer) - the GMF diagram outline page (SynchronizableGmfDiagramEditor)
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java89
1 files changed, 87 insertions, 2 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
index dd03f4261d3..f635e5157f7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
+ * Copyright (c) 2010, 2014 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,6 +9,7 @@
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 437217
+ * Christian W. Damus - bug 451683
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common;
@@ -30,6 +30,7 @@ import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.gef.ui.parts.ContentOutlinePage;
import org.eclipse.gef.ui.views.palette.PalettePage;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -45,6 +46,8 @@ import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.papyrus.commands.CheckedDiagramCommandStack;
@@ -64,9 +67,12 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -202,6 +208,13 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
palettePages.add(result);
return result;
}
+ if (type == IContentOutlinePage.class) {
+ Object result = super.getAdapter(type);
+ if (result instanceof ContentOutlinePage) {
+ result = new OutlinePageWrapper((ContentOutlinePage) result);
+ }
+ return result;
+ }
return super.getAdapter(type);
}
@@ -540,4 +553,76 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
}
+ /**
+ * A wrapper for the GMF-provided outline page that lets us clean up references to the model content leaked via the Outline View tool bar.
+ */
+ private class OutlinePageWrapper implements IPageBookViewPage, IContentOutlinePage {
+ private final ContentOutlinePage delegate;
+
+ OutlinePageWrapper(ContentOutlinePage delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ delegate.createControl(parent);
+ }
+
+ @Override
+ public void dispose() {
+ try {
+ // Remove the toolbar items that reference me and, through me, the diagram and its associated semantic model
+ IActionBars bars = getSite().getActionBars();
+ bars.getToolBarManager().removeAll();
+ bars.updateActionBars();
+ } finally {
+ delegate.dispose();
+ }
+ }
+
+ @Override
+ public Control getControl() {
+ return delegate.getControl();
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ delegate.setActionBars(actionBars);
+ }
+
+ @Override
+ public void setFocus() {
+ delegate.setFocus();
+ }
+
+ @Override
+ public void init(IPageSite site) throws PartInitException {
+ delegate.init(site);
+ }
+
+ @Override
+ public IPageSite getSite() {
+ return delegate.getSite();
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ delegate.addSelectionChangedListener(listener);
+ }
+
+ @Override
+ public ISelection getSelection() {
+ return delegate.getSelection();
+ }
+
+ @Override
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ delegate.removeSelectionChangedListener(listener);
+ }
+
+ @Override
+ public void setSelection(ISelection selection) {
+ delegate.setSelection(selection);
+ }
+ }
}

Back to the top