mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 346129 - stack overflow crash when moving in renderer.
This commit is contained in:
parent
7bda52bcdb
commit
2305812d98
1 changed files with 39 additions and 21 deletions
|
@ -520,21 +520,20 @@ public abstract class AbstractPane extends Canvas
|
||||||
protected void ensureCaretWithinViewport() // TODO getAddressableSize() > 1 ?
|
protected void ensureCaretWithinViewport() // TODO getAddressableSize() > 1 ?
|
||||||
{
|
{
|
||||||
BigInteger vpStart = fRendering.getViewportStartAddress();
|
BigInteger vpStart = fRendering.getViewportStartAddress();
|
||||||
BigInteger vpEnd = fRendering.getViewportEndAddress();
|
BigInteger vpEnd = fRendering.getViewportEndAddress();
|
||||||
|
|
||||||
//Rectangle paneBounds = null;
|
Rectangle vpBounds = fRendering.getBounds();
|
||||||
Rectangle vpBounds = fRendering.getBounds();
|
Rectangle apBounds = fRendering.fAddressPane.getBounds();
|
||||||
Rectangle apBounds = fRendering.fAddressPane.getBounds();
|
Rectangle dpBounds = fRendering.fBinaryPane.getBounds();
|
||||||
Rectangle dpBounds = fRendering.fBinaryPane.getBounds();
|
Rectangle tpBounds = fRendering.fTextPane.getBounds();
|
||||||
Rectangle tpBounds = fRendering.fTextPane.getBounds();
|
|
||||||
|
|
||||||
ScrollBar hBar = fRendering.getHorizontalBar();
|
ScrollBar hBar = fRendering.getHorizontalBar();
|
||||||
|
|
||||||
Point adjustedCaret = null;
|
Point adjustedCaret = null;
|
||||||
|
|
||||||
int leftPaneEdge = 0;
|
int leftPaneEdge = 0;
|
||||||
int rightPaneEdge = 0;
|
int rightPaneEdge = 0;
|
||||||
int eolComparison = 0;
|
int eolLocation = 0;
|
||||||
int bolSelection = 0;
|
int bolSelection = 0;
|
||||||
int eolSelection = 0;
|
int eolSelection = 0;
|
||||||
|
|
||||||
|
@ -550,7 +549,7 @@ public abstract class AbstractPane extends Canvas
|
||||||
rightPaneEdge = vpBounds.x + vpBounds.width;
|
rightPaneEdge = vpBounds.x + vpBounds.width;
|
||||||
bolSelection = hBar.getMinimum();
|
bolSelection = hBar.getMinimum();
|
||||||
eolSelection = apBounds.width + dpBounds.width - (vpBounds.width/2);
|
eolSelection = apBounds.width + dpBounds.width - (vpBounds.width/2);
|
||||||
eolComparison = apBounds.width + dpBounds.width - 10;
|
eolLocation = apBounds.width + dpBounds.width - 10;
|
||||||
adjustedCaret = new Point(fCaret.getLocation().x + dpBounds.x + 16, fCaret.getLocation().y);
|
adjustedCaret = new Point(fCaret.getLocation().x + dpBounds.x + 16, fCaret.getLocation().y);
|
||||||
}
|
}
|
||||||
else if (this instanceof TextPane)
|
else if (this instanceof TextPane)
|
||||||
|
@ -559,7 +558,7 @@ public abstract class AbstractPane extends Canvas
|
||||||
rightPaneEdge = leftPaneEdge + (vpBounds.width - tpBounds.x);
|
rightPaneEdge = leftPaneEdge + (vpBounds.width - tpBounds.x);
|
||||||
bolSelection = apBounds.width + dpBounds.width - 36;
|
bolSelection = apBounds.width + dpBounds.width - 36;
|
||||||
eolSelection = hBar.getMaximum();
|
eolSelection = hBar.getMaximum();
|
||||||
eolComparison = apBounds.width + dpBounds.width + tpBounds.width - 22;
|
eolLocation = apBounds.width + dpBounds.width + tpBounds.width - 22;
|
||||||
adjustedCaret = new Point(fCaret.getLocation().x + apBounds.width + dpBounds.width, fCaret.getLocation().y);
|
adjustedCaret = new Point(fCaret.getLocation().x + apBounds.width + dpBounds.width, fCaret.getLocation().y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -567,18 +566,37 @@ public abstract class AbstractPane extends Canvas
|
||||||
|
|
||||||
if (fCaretAddress.compareTo(vpStart) < 0 || fCaretAddress.compareTo(vpEnd) >= 0)
|
if (fCaretAddress.compareTo(vpStart) < 0 || fCaretAddress.compareTo(vpEnd) >= 0)
|
||||||
{
|
{
|
||||||
// Up or Down arrow: Scroll the viewport up or down by one row.
|
// The caret was moved outside the viewport bounds: Scroll the
|
||||||
|
// viewport up or down by a row, depending on where the caret is
|
||||||
|
|
||||||
ScrollBar vBar = fRendering.getVerticalBar();
|
boolean upArrow = fCaretAddress.compareTo(vpStart) <= 0;
|
||||||
vBar.setSelection(vBar.getSelection() + (fCaretAddress.compareTo(vpStart) <= 0 ? -1 : 1));
|
ScrollBar vBar = fRendering.getVerticalBar();
|
||||||
vBar.notifyListeners(SWT.Selection, new Event());
|
vBar.setSelection(vBar.getSelection() + (upArrow ? -1 : 1));
|
||||||
ensureCaretWithinViewport();
|
vBar.notifyListeners(SWT.Selection, new Event());
|
||||||
|
|
||||||
|
// Check to see if we're at the beginning or end of a line, and
|
||||||
|
// move the scrollbar, if necessary, to keep the caret in view.
|
||||||
|
|
||||||
|
int currentCaretLocation = fCaret.getLocation().x + dpBounds.x + 16;
|
||||||
|
int lowEolLimit = eolLocation - 1;
|
||||||
|
int highEolLimit = eolLocation + 1;
|
||||||
|
|
||||||
|
if (fCaret.getLocation().x == 2)
|
||||||
|
{
|
||||||
|
hBar.setSelection(bolSelection);
|
||||||
|
hBar.notifyListeners(SWT.Selection, new Event());
|
||||||
|
}
|
||||||
|
else if (upArrow && ((currentCaretLocation >= lowEolLimit && currentCaretLocation <= highEolLimit)))
|
||||||
|
{
|
||||||
|
hBar.setSelection(eolSelection);
|
||||||
|
hBar.notifyListeners(SWT.Selection, new Event());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!vpBounds.contains(adjustedCaret))
|
else if (!vpBounds.contains(adjustedCaret))
|
||||||
{
|
{
|
||||||
// Left or Right arrow: The caret is now outside the viewport and beyond the pane. Calculate
|
// Left or Right arrow: The caret is now outside the viewport and beyond the pane. Calculate
|
||||||
// a new pane position at [up to] 33% left or right in the viewport, to center the caret; use a
|
// a new pane position at [up to] 33% left or right in the viewport, to center the caret; use a
|
||||||
// positive or negative offset depending on which direction we're scrolling.
|
// positive or negative offset depending on which direction we're scrolling.
|
||||||
|
|
||||||
int hBarOffset = (rightPaneEdge - leftPaneEdge) / 3;
|
int hBarOffset = (rightPaneEdge - leftPaneEdge) / 3;
|
||||||
int newHBarSel = hBar.getSelection() + (adjustedCaret.x > rightPaneEdge ? hBarOffset : -hBarOffset);
|
int newHBarSel = hBar.getSelection() + (adjustedCaret.x > rightPaneEdge ? hBarOffset : -hBarOffset);
|
||||||
|
@ -588,10 +606,10 @@ public abstract class AbstractPane extends Canvas
|
||||||
// Beginning of a line
|
// Beginning of a line
|
||||||
hBar.setSelection(bolSelection);
|
hBar.setSelection(bolSelection);
|
||||||
}
|
}
|
||||||
else if (adjustedCaret.x == eolComparison)
|
else if (adjustedCaret.x == eolLocation)
|
||||||
{
|
{
|
||||||
// End of a line
|
// End of a line
|
||||||
hBar.setSelection(eolSelection);
|
hBar.setSelection(eolSelection);
|
||||||
}
|
}
|
||||||
else if (adjustedCaret.x > rightPaneEdge)
|
else if (adjustedCaret.x > rightPaneEdge)
|
||||||
{
|
{
|
||||||
|
@ -610,7 +628,7 @@ public abstract class AbstractPane extends Canvas
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Caret is inside the viewport
|
// Caret is inside the viewport
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue