diff options
author | Stefan Xenos | 2016-03-05 03:04:44 +0000 |
---|---|---|
committer | Arun Thondapu | 2016-03-07 20:12:28 +0000 |
commit | 6a7d8fc08c1e35a31eac6c248bfb4946531f480e (patch) | |
tree | 32df411172b34b84277c54b5525d2d152e5766c9 | |
parent | 61ab7c50fa5643888ae6d099f8948f3ceb5b80a8 (diff) | |
download | eclipse.platform.swt-6a7d8fc08c1e35a31eac6c248bfb4946531f480e.tar.gz eclipse.platform.swt-6a7d8fc08c1e35a31eac6c248bfb4946531f480e.tar.xz eclipse.platform.swt-6a7d8fc08c1e35a31eac6c248bfb4946531f480e.zip |
Bug 487254 - StyledText.getTopIndex() can return negative values
Clamp all assignments to topIndex such that the result will never be
negative.
Add error logging to help identify the root cause of the issue.
Change-Id: I90da4f73d08c0328d43a4958c66968ff9c470b21
Signed-off-by: Stefan Xenos <sxenos@gmail.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java index 961821a209..f34c6d421b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Andrey Loskutov <loskutov@gmx.de> - bug 488172 + * Stefan Xenos (Google) - bug 487254 - StyledText.getTopIndex() can return negative values *******************************************************************************/ package org.eclipse.swt.custom; @@ -1573,6 +1574,7 @@ void calculateScrollBars() { * The top index starts at 0. */ void calculateTopIndex(int delta) { + int oldDelta = delta; int oldTopIndex = topIndex; int oldTopIndexY = topIndexY; if (isFixedLineHeight()) { @@ -1633,6 +1635,21 @@ void calculateTopIndex(int delta) { } } } + if (topIndex < 0) { + // TODO: This logging is in place to determine why topIndex is getting set to negative values. + // It should be deleted once we fix the root cause of this issue. See bug 487254 for details. + System.err.println("StyledText: topIndex was " + topIndex + + ", isFixedLineHeight() = " + isFixedLineHeight() + + ", delta = " + delta + + ", content.getLineCount() = " + content.getLineCount() + + ", clientAreaHeight = " + clientAreaHeight + + ", oldTopIndex = " + oldTopIndex + + ", oldTopIndexY = " + oldTopIndexY + + ", getVerticalScrollOffset = " + getVerticalScrollOffset() + + ", oldDelta = " + oldDelta + + ", getVerticalIncrement() = " + getVerticalIncrement()); + topIndex = 0; + } if (topIndex != oldTopIndex || oldTopIndexY != topIndexY) { int width = renderer.getWidth(); renderer.calculateClientArea(); @@ -6272,6 +6289,15 @@ void handleTextChanged(TextChangedEvent event) { resetCache(firstLine, 0); if (!isFixedLineHeight() && topIndex > firstLine) { topIndex = firstLine; + if (topIndex < 0) { + // TODO: This logging is in place to determine why topIndex is getting set to negative values. + // It should be deleted once we fix the root cause of this issue. See bug 487254 for details. + System.err.println("StyledText: topIndex was " + topIndex + + ", lastTextChangeStart = " + lastTextChangeStart + + ", content.getClass() = " + content.getClass() + ); + topIndex = 0; + } topIndexY = 0; super.redraw(); } else { |