Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2016-05-20 19:31:23 +0000
committerEric Williams2016-05-25 12:41:45 +0000
commit83f68458d1ae8ca986e87c6cf49dcb5c4bf9ba65 (patch)
treea84eaeac3d1d33e66840a718dcce5c5aaaf8af52 /bundles
parent4b9b50badaff569fcc309f571d44e11426375523 (diff)
downloadeclipse.platform.swt-83f68458d1ae8ca986e87c6cf49dcb5c4bf9ba65.tar.gz
eclipse.platform.swt-83f68458d1ae8ca986e87c6cf49dcb5c4bf9ba65.tar.xz
eclipse.platform.swt-83f68458d1ae8ca986e87c6cf49dcb5c4bf9ba65.zip
Bug 487467: [GTK3] org_eclipse_swt_widgets_Text.test_getTopIndex fails
This is an additional fix for a regression caused in the original patch to this bug. The regression can be tested using Snippet243. Typing in the text box will crash GTK. We need to handle the case where getTopIndex() is called *without* calling setTopIndex() first or scrolling in the UI. This can be covered by checking to make sure indexMark is not 0. If indexMark is 0, don't use it and use gtk_text_view_get_visible_rect() and gtk_text_view_get_line_at_y() to fetch the topIndex instead. Tested on GTK3.20, 3.18, 3.16, and 3.14. No additional AllNonBrowser JUnit test failures on GTK3 or GTK2. Snippet243 no longer crashes. Change-Id: I0477ef19d2303271b1ed62a8159727e6d492ca76 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index f61d5b14a0..6ad35e5bdd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -102,7 +102,7 @@ public class Text extends Scrollable {
* a global variable to keep track of its background color.
*/
GdkRGBA background;
- long /*int*/ indexMark;
+ long /*int*/ indexMark = 0;
double cachedAdjustment, currentAdjustment;
/**
@@ -1421,8 +1421,11 @@ public int getTopIndex () {
long /*int*/ vAdjustment = OS.gtk_scrollable_get_vadjustment (handle);
currentAdjustment = OS.gtk_adjustment_get_value (vAdjustment);
if (cachedAdjustment == currentAdjustment) {
- OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, indexMark);
- return OS.gtk_text_iter_get_line (position);
+ // If indexMark is 0, fetch topIndex using the old method
+ if (indexMark != 0) {
+ OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, indexMark);
+ return OS.gtk_text_iter_get_line (position);
+ }
}
}
GdkRectangle rect = new GdkRectangle ();

Back to the top