Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2012-01-23 08:11:49 -0500
committerAnton Leherbauer2012-01-23 08:12:07 -0500
commit8df0648343ce6283e92a6dd0c3eb6380a614a4cc (patch)
tree1d6bb4fa110bf20583a9acf9c348be2fa3a08a3f
parent873e3587aeb14a8c73f5dd2f0b6ab0d7635a9823 (diff)
downloadorg.eclipse.cdt-8df0648343ce6283e92a6dd0c3eb6380a614a4cc.tar.gz
org.eclipse.cdt-8df0648343ce6283e92a6dd0c3eb6380a614a4cc.tar.xz
org.eclipse.cdt-8df0648343ce6283e92a6dd0c3eb6380a614a4cc.zip
Bug 369350 - CMacroExpansionInput is referenced even if macro expansion is closed, wasting memory
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java27
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java10
4 files changed, 41 insertions, 17 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
index 80721b725a..df67cc2f7c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2012 Wind River Systems, Inc. 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
@@ -234,6 +234,14 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips
}
@Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (!visible) {
+ setInput(null);
+ }
+ }
+
+ @Override
public void dispose() {
if (!fIsSystemBackgroundColor) {
fBackgroundColor.dispose();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
index 0122af6f4c..d392356e60 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2012 Wind River Systems, Inc. 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
@@ -199,20 +199,21 @@ class CMacroCompareViewer extends CMergeViewer {
fLeftViewer.setRedraw(false);
fRightViewer.setRedraw(false);
}
- final ReplaceEdit[] edits;
+ ReplaceEdit[] edits = null;
try {
- final IMacroExpansionStep step;
- if (fStepIndex < fInput.fExplorer.getExpansionStepCount()) {
- step= fInput.fExplorer.getExpansionStep(fStepIndex);
- } else {
- step= fInput.fExplorer.getFullExpansion();
- }
- edits= step.getReplacements();
-
- fLeftHighlighter.setReplaceEdits(fPrefixLength, edits);
- fRightHighlighter.setReplaceEdits(fPrefixLength, edits);
+ if (fInput != null) {
+ final IMacroExpansionStep step;
+ if (fStepIndex < fInput.fExplorer.getExpansionStepCount()) {
+ step= fInput.fExplorer.getExpansionStep(fStepIndex);
+ } else {
+ step= fInput.fExplorer.getFullExpansion();
+ }
+ edits= step.getReplacements();
+ fLeftHighlighter.setReplaceEdits(fPrefixLength, edits);
+ fRightHighlighter.setReplaceEdits(fPrefixLength, edits);
+ }
super.setInput(input);
} finally {
@@ -221,7 +222,7 @@ class CMacroCompareViewer extends CMergeViewer {
fRightViewer.setRedraw(true);
}
}
- if (edits.length > 0) {
+ if (edits != null && edits.length > 0) {
if (fLeftViewer != null && fRightViewer != null) {
final int firstDiffOffset= fPrefixLength + edits[0].getOffset();
fLeftViewer.revealRange(firstDiffOffset, edits[0].getLength());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
index 10b2d81355..2ee273679d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2012 Wind River Systems, Inc. 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
@@ -64,10 +64,19 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
fInput= macroExpansionInput;
updateStatusText();
} else {
+ fInput = null;
super.setInput(input);
}
}
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (!visible) {
+ setInput(null);
+ }
+ }
+
private void updateStatusText() {
if (fInput == null) {
return;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
index 9b0ee8018c..888bd2050a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2012 Wind River Systems, Inc. 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
@@ -450,11 +450,14 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
public void setInput(Object input) {
if (input instanceof CMacroExpansionInput) {
setMacroExpansionInput((CMacroExpansionInput) input);
- } else {
+ } else if (input != null) {
if (fMacroCompareViewer != null) {
fMacroCompareViewer.setMacroExpansionStep(fIndex);
}
super.setInput(input);
+ } else {
+ setMacroExpansionInput(null);
+ super.setInput(input);
}
}
@@ -507,6 +510,9 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
*/
private void setMacroExpansionInput(CMacroExpansionInput input) {
fInput= input;
+ if (fMacroCompareViewer != null) {
+ fMacroCompareViewer.setMacroExpansionInput(input);
+ }
if (fInput != null) {
fIndex= fixIndex(input.fStartWithFullExpansion ? getStepCount() : 0);
showExpansion();

Back to the top