summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSnjezana Peco2013-01-10 13:29:16 (EST)
committer Nick Sandonato2013-01-14 17:01:25 (EST)
commit278329357db66529136a29771cee0404990558c7 (patch)
tree0f7c8ab58795a5e2427d2176fc684985835ed859
parentd80df6676916dd3a65a2efcbffd33b5902759d7c (diff)
downloadwebtools.sourceediting-278329357db66529136a29771cee0404990558c7.zip
webtools.sourceediting-278329357db66529136a29771cee0404990558c7.tar.gz
webtools.sourceediting-278329357db66529136a29771cee0404990558c7.tar.bz2
[397904] Memory leaks in Juno when opening and closing XML Editor
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java25
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/StructuredContentAssistProcessor.java2
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java10
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java3
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/StructuredContentAssistant.java1
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/propertytester/CustomFilterPropertyTester.java5
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java48
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java14
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java13
9 files changed, 83 insertions, 38 deletions
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
index f92cbbc..490cf0e 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2012 IBM Corporation and others.
+ * Copyright (c) 2001, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -105,6 +105,8 @@ import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -1112,7 +1114,7 @@ public class StructuredTextEditor extends TextEditor {
private boolean fSelectionChangedFromGoto = false;
- private final CharacterPairListener fPairInserter = new CharacterPairListener();
+ private CharacterPairListener fPairInserter = new CharacterPairListener();
/**
* Creates a new Structured Text Editor.
@@ -1759,6 +1761,7 @@ public class StructuredTextEditor extends TextEditor {
}
if (fRulerContextMenu != null) {
fRulerContextMenu.dispose();
+ fRulerContextMenu = null;
}
if (fTextContextMenuManager != null) {
fTextContextMenuManager.removeMenuListener(getContextMenuListener());
@@ -1802,6 +1805,7 @@ public class StructuredTextEditor extends TextEditor {
if (fOutlinePageListener != null) {
fOutlinePage.removeSelectionChangedListener(fOutlinePageListener);
}
+ fOutlinePage = null;
}
fEditorDisposed = true;
@@ -1817,8 +1821,9 @@ public class StructuredTextEditor extends TextEditor {
uninstallSemanticHighlighting();
- if (fPairInserter != null)
+ if (fPairInserter != null) {
fPairInserter.dispose();
+ }
setPreferenceStore(null);
@@ -1834,6 +1839,10 @@ public class StructuredTextEditor extends TextEditor {
if (fStructuredSelectionProvider != null) {
fStructuredSelectionProvider.dispose();
}
+
+ if (fStatusLineLabelProvider != null) {
+ fStatusLineLabelProvider.dispose();
+ }
setStatusLineMessage(null);
@@ -2083,7 +2092,7 @@ public class StructuredTextEditor extends TextEditor {
}
// content outline page
else if (IContentOutlinePage.class.equals(required)) {
- if (fOutlinePage == null || fOutlinePage.getControl() == null || fOutlinePage.getControl().isDisposed()) {
+ if (fOutlinePage == null) {
ContentOutlineConfiguration cfg = createContentOutlineConfiguration();
if (cfg != null) {
ConfigurableContentOutlinePage outlinePage = new ConfigurableContentOutlinePage();
@@ -2637,6 +2646,14 @@ public class StructuredTextEditor extends TextEditor {
fDropAdapter.setTextViewer(textViewer);
fDropTarget.setTransfer(fDropAdapter.getTransfers());
fDropTarget.addDropListener(fDropAdapter);
+ fDropTarget.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ fDropTarget.removeDropListener(fDropAdapter);
+ fDropTarget.removeDisposeListener(this);
+ fDropTarget.dispose();
+ }
+ });
}
/*
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/StructuredContentAssistProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/StructuredContentAssistProcessor.java
index 78efc28..a2ad169 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/StructuredContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/StructuredContentAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java
index f7e3650..198fac2 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * Copyright (c) 2001, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -715,6 +715,14 @@ public class StructuredTextViewer extends ProjectionViewer implements IDocumentS
fRecHighlighter.uninstall();
fRecHighlighter = null;
}
+ if (fContentAssistant != null) {
+ fContentAssistant.uninstall();
+ if (fContentAssistantFacade != null) {
+ fContentAssistantFacade= null;
+ }
+ fContentAssistantInstalled = false;
+ fContentAssistant = null;
+ }
super.handleDispose();
Logger.trace("Source Editor", "StructuredTextViewer::handleDispose exit"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java
index 7e89b43..f76003e 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -375,6 +375,7 @@ public class CompoundContentAssistProcessor implements IContentAssistProcessor,
((IReleasable) p).release();
}
}
+ fProcessors.clear();
}
private static class WrappedContextInformation implements IContextInformation, IContextInformationExtension {
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/StructuredContentAssistant.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/StructuredContentAssistant.java
index 8d124ce..53e9d51 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/StructuredContentAssistant.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/StructuredContentAssistant.java
@@ -119,6 +119,7 @@ public class StructuredContentAssistant extends ContentAssistant {
}
}
fProcessorsReleased = true;
+ this.fReleasableProcessors.clear();
super.uninstall();
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/propertytester/CustomFilterPropertyTester.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/propertytester/CustomFilterPropertyTester.java
index e4fa4d7..d1cd362 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/propertytester/CustomFilterPropertyTester.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/propertytester/CustomFilterPropertyTester.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 IBM Corporation and others.
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,7 +24,8 @@ public class CustomFilterPropertyTester extends PropertyTester {
*/
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (receiver instanceof IEditorPart){
- return ((IEditorPart) receiver).getAdapter(IContentOutlinePage.class) instanceof ConfigurableContentOutlinePage;
+ IContentOutlinePage outlinePage = (IContentOutlinePage) ((IEditorPart) receiver).getAdapter(IContentOutlinePage.class);
+ return (outlinePage instanceof ConfigurableContentOutlinePage && outlinePage.getControl() != null && !outlinePage.getControl().isDisposed());
}
return false;
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java
index 014eb75..5e8c942 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2004, 2013 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and
* is available at http://www.eclipse.org/legal/epl-v10.html
@@ -74,8 +74,6 @@ import org.eclipse.ui.part.MultiPageEditorSite;
import org.eclipse.ui.part.MultiPageSelectionProvider;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextSelectionNavigationLocation;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
@@ -491,6 +489,8 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements INavi
private MenuManager fMenuManager;
private boolean fAllocateToolbar = true;
+
+ private TextInputListener fTextInputListener;
/**
* StructuredTextMultiPageEditorPart constructor comment.
@@ -520,7 +520,8 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements INavi
// Changes to the Text Viewer's document instance should also
// force an
// input refresh
- fTextEditor.getTextViewer().addTextInputListener(new TextInputListener());
+ fTextInputListener = new TextInputListener();
+ fTextEditor.getTextViewer().addTextInputListener(fTextInputListener);
}
/**
@@ -861,7 +862,12 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements INavi
public void dispose() {
Logger.trace("Source Editor", "XMLMultiPageEditorPart::dispose entry"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (fTextInputListener != null) {
+ fTextEditor.getTextViewer().removeTextInputListener(fTextInputListener);
+ fTextInputListener = null;
+ }
disconnectDesignPage();
+ fDesignViewer = null;
if (fActivationListener != null) {
fActivationListener.dispose();
@@ -874,15 +880,27 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements INavi
fMenuManager = null;
}
- if ((fTextEditor != null) && (fPropertyListener != null)) {
+ if (fPropertyListener != null) {
fTextEditor.removePropertyListener(fPropertyListener);
+ fPropertyListener = null;
}
+ if (fEditorManager != null) {
+ fEditorManager.dispose();
+ fEditorManager = null;
+ }
+ if (fToolbarManager != null) {
+ fToolbarManager.dispose();
+ fToolbarManager = null;
+ }
// moved to last when added window ... seems like
// we'd be in danger of losing some data, like site,
// or something.
super.dispose();
+ fTextEditor = null;
+ fPageInitializer = null;
+
Logger.trace("Source Editor", "StructuredTextMultiPageEditorPart::dispose exit"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -1136,15 +1154,7 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements INavi
return new DesignPageNavigationLocation(this, fDesignViewer, false);
}
// Makes sure that the text editor is returned
- return new TextSelectionNavigationLocation(fTextEditor, false) {
- protected IEditorPart getEditorPart() {
- IEditorPart part = super.getEditorPart();
- if (part != null) {
- part = (ITextEditor) part.getAdapter(ITextEditor.class);
- }
- return part;
- }
- };
+ return fTextEditor.createEmptyNavigationLocation();
}
public INavigationLocation createNavigationLocation() {
@@ -1152,15 +1162,7 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements INavi
return new DesignPageNavigationLocation(this, fDesignViewer, true);
}
// Makes sure that the text editor is returned
- return new TextSelectionNavigationLocation(fTextEditor, true) {
- protected IEditorPart getEditorPart() {
- IEditorPart part = super.getEditorPart();
- if (part != null) {
- part = (ITextEditor) part.getAdapter(ITextEditor.class);
- }
- return part;
- }
- };
+ return fTextEditor.createNavigationLocation();
}
public void saveState(IMemento memento) {
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java
index 4af5032..10a5707 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -54,6 +54,7 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC
protected ViewerExpandCollapseAction collapseAction;
protected ViewerExpandCollapseAction xmlMenuExpandAction;
protected ViewerExpandCollapseAction xmlMenuCollapseAction;
+ private IActionBars actionBars;
public XMLTableTreeActionBarContributor() {
}
@@ -88,6 +89,7 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC
}
public void init(IActionBars bars) {
+ this.actionBars = bars;
// IToolBarManager tbm = bars.getToolBarManager();
/* IMenuManager xmlMenu = bars.getMenuManager().findMenuUsingPath("org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$
@@ -184,15 +186,16 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC
xmlMenuCollapseAction.setViewer(tableTreeViewer);
}
*/
+ ITextEditor textEditor = null;
if (editorPart instanceof XMLMultiPageEditorPart) {
IWorkbenchPartSite site = editorPart.getSite();
if (site instanceof IEditorSite) {
- ITextEditor textEditor = ((XMLMultiPageEditorPart) editorPart).getTextEditor();
- IActionBars actionBars = ((IEditorSite) site).getActionBars();
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, getAction(textEditor, ITextEditorActionConstants.UNDO));
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, getAction(textEditor, ITextEditorActionConstants.REDO));
+ textEditor = ((XMLMultiPageEditorPart) editorPart).getTextEditor();
}
}
+ actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, getAction(textEditor, ITextEditorActionConstants.UNDO));
+ actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, getAction(textEditor, ITextEditorActionConstants.REDO));
+
// TODO... uncomment this and investigate NPE
//
@@ -317,5 +320,6 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC
* @see org.eclipse.ui.IEditorActionBarContributor#dispose()
*/
public void dispose() {
+ setActiveEditor(null);
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
index 4b90cfb..1cb7f23 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * Copyright (c) 2001, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,6 +13,9 @@
package org.eclipse.wst.xml.ui.internal;
+import java.util.Collection;
+import java.util.Iterator;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -164,6 +167,14 @@ public class DOMObserver {
if (fDocument != null) {
// here we create and init an adapter that will listen to
// changes to the document and contained elements
+ Collection adapters = ((INodeNotifier) fDocument).getAdapters();
+ Iterator iterator = adapters.iterator();
+ while (iterator.hasNext()) {
+ INodeAdapter adapter = (INodeAdapter) iterator.next();
+ if (adapter instanceof MyDocumentAdapter) {
+ return;
+ }
+ }
MyDocumentAdapter adapter = new MyDocumentAdapter();
adapter.connect(fDocument);