1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Bug 369350 - CMacroExpansionInput is referenced even if macro expansion is closed, wasting memory

This commit is contained in:
Anton Leherbauer 2012-01-23 14:11:49 +01:00
parent 873e3587ae
commit 8df0648343
4 changed files with 41 additions and 17 deletions

View file

@ -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
@ -233,6 +233,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) {

View file

@ -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());

View file

@ -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;

View file

@ -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();