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
|
@ -522,7 +522,6 @@ public abstract class AbstractPane extends Canvas
|
||||||
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();
|
||||||
|
@ -534,7 +533,7 @@ public abstract class AbstractPane extends Canvas
|
||||||
|
|
||||||
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,12 +566,31 @@ 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
|
||||||
|
|
||||||
|
boolean upArrow = fCaretAddress.compareTo(vpStart) <= 0;
|
||||||
ScrollBar vBar = fRendering.getVerticalBar();
|
ScrollBar vBar = fRendering.getVerticalBar();
|
||||||
vBar.setSelection(vBar.getSelection() + (fCaretAddress.compareTo(vpStart) <= 0 ? -1 : 1));
|
vBar.setSelection(vBar.getSelection() + (upArrow ? -1 : 1));
|
||||||
vBar.notifyListeners(SWT.Selection, new Event());
|
vBar.notifyListeners(SWT.Selection, new Event());
|
||||||
ensureCaretWithinViewport();
|
|
||||||
|
// 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))
|
||||||
{
|
{
|
||||||
|
@ -588,7 +606,7 @@ 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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue