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 80721b725ad..df67cc2f7c8 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 @@ -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) { 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 0122af6f4cd..d392356e60a 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 10b2d813551..2ee273679d5 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 9b0ee8018c4..888bd2050a5 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();