1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56: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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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 @Override
public void dispose() { public void dispose() {
if (!fIsSystemBackgroundColor) { 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -199,9 +199,10 @@ class CMacroCompareViewer extends CMergeViewer {
fLeftViewer.setRedraw(false); fLeftViewer.setRedraw(false);
fRightViewer.setRedraw(false); fRightViewer.setRedraw(false);
} }
final ReplaceEdit[] edits; ReplaceEdit[] edits = null;
try { try {
if (fInput != null) {
final IMacroExpansionStep step; final IMacroExpansionStep step;
if (fStepIndex < fInput.fExplorer.getExpansionStepCount()) { if (fStepIndex < fInput.fExplorer.getExpansionStepCount()) {
step= fInput.fExplorer.getExpansionStep(fStepIndex); step= fInput.fExplorer.getExpansionStep(fStepIndex);
@ -212,7 +213,7 @@ class CMacroCompareViewer extends CMergeViewer {
fLeftHighlighter.setReplaceEdits(fPrefixLength, edits); fLeftHighlighter.setReplaceEdits(fPrefixLength, edits);
fRightHighlighter.setReplaceEdits(fPrefixLength, edits); fRightHighlighter.setReplaceEdits(fPrefixLength, edits);
}
super.setInput(input); super.setInput(input);
} finally { } finally {
@ -221,7 +222,7 @@ class CMacroCompareViewer extends CMergeViewer {
fRightViewer.setRedraw(true); fRightViewer.setRedraw(true);
} }
} }
if (edits.length > 0) { if (edits != null && edits.length > 0) {
if (fLeftViewer != null && fRightViewer != null) { if (fLeftViewer != null && fRightViewer != null) {
final int firstDiffOffset= fPrefixLength + edits[0].getOffset(); final int firstDiffOffset= fPrefixLength + edits[0].getOffset();
fLeftViewer.revealRange(firstDiffOffset, edits[0].getLength()); 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -64,10 +64,19 @@ public class CMacroExpansionControl extends AbstractSourceViewerInformationContr
fInput= macroExpansionInput; fInput= macroExpansionInput;
updateStatusText(); updateStatusText();
} else { } else {
fInput = null;
super.setInput(input); super.setInput(input);
} }
} }
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (!visible) {
setInput(null);
}
}
private void updateStatusText() { private void updateStatusText() {
if (fInput == null) { if (fInput == null) {
return; 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -450,11 +450,14 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
public void setInput(Object input) { public void setInput(Object input) {
if (input instanceof CMacroExpansionInput) { if (input instanceof CMacroExpansionInput) {
setMacroExpansionInput((CMacroExpansionInput) input); setMacroExpansionInput((CMacroExpansionInput) input);
} else { } else if (input != null) {
if (fMacroCompareViewer != null) { if (fMacroCompareViewer != null) {
fMacroCompareViewer.setMacroExpansionStep(fIndex); fMacroCompareViewer.setMacroExpansionStep(fIndex);
} }
super.setInput(input); super.setInput(input);
} else {
setMacroExpansionInput(null);
super.setInput(input);
} }
} }
@ -507,6 +510,9 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo
*/ */
private void setMacroExpansionInput(CMacroExpansionInput input) { private void setMacroExpansionInput(CMacroExpansionInput input) {
fInput= input; fInput= input;
if (fMacroCompareViewer != null) {
fMacroCompareViewer.setMacroExpansionInput(input);
}
if (fInput != null) { if (fInput != null) {
fIndex= fixIndex(input.fStartWithFullExpansion ? getStepCount() : 0); fIndex= fixIndex(input.fStartWithFullExpansion ? getStepCount() : 0);
showExpansion(); showExpansion();