Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArne Deutsch2017-08-04 08:29:34 -0400
committerLeo Ufimtsev2017-08-18 11:06:04 -0400
commit4610363d0b2ed6494338d486beb57127e6009d22 (patch)
treee6eede0fd0db40cfead97f9c91edba6410cf0662 /tests
parentf28f8cb0510c91905751bee0f128e0912d8324c8 (diff)
downloadeclipse.platform.swt-4610363d0b2ed6494338d486beb57127e6009d22.tar.gz
eclipse.platform.swt-4610363d0b2ed6494338d486beb57127e6009d22.tar.xz
eclipse.platform.swt-4610363d0b2ed6494338d486beb57127e6009d22.zip
[Bug 500475] Guard 'doubleClickSelection' with 'doubleClickEnabled'.
The field 'doubleClickSelection' might be accessed only in case 'doubleClickEnabled' is true. Otherwise it will be null and NPE is the result. In case 'doubleClickEnabled = false" 'selectionAnchor' will already have the correct value. Added snippet to reproduce bug. Change-Id: Id5743435fd231dc03df8376122495a51b9bcb662 Signed-off-by: Arne Deutsch <arne@idedeluxe.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests/BugSnippets/Bug500475_StyledText_NPE_on_selection_drag.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests/BugSnippets/Bug500475_StyledText_NPE_on_selection_drag.java b/tests/org.eclipse.swt.tests/BugSnippets/Bug500475_StyledText_NPE_on_selection_drag.java
new file mode 100644
index 0000000000..11d329b52e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests/BugSnippets/Bug500475_StyledText_NPE_on_selection_drag.java
@@ -0,0 +1,34 @@
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Description: StyledText NPE on selection drag.
+ * Steps to reproduce: Double click in the text but do not release the mouse button after second click. Drag around
+ * the text such that scrolling of the text widget does happen.
+ * Expected results: No exceptions should be raised.
+ * Actual results: Application dies because of NPE.
+ */
+public class Bug500475_StyledText_NPE_on_selection_drag {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ final Shell shell = new Shell(display);
+ shell.setSize(200, 200);
+ shell.setLayout(new FillLayout());
+
+ StyledText text = new StyledText(shell, SWT.BORDER);
+ text.setDoubleClickEnabled(false); // exception does happen only if this flag is 'false'
+ text.setText("This is some dummy text. We need enough text to have the scroll bars appear.");
+
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+}

Back to the top