diff options
author | Arne Deutsch | 2017-08-04 12:29:34 +0000 |
---|---|---|
committer | Leo Ufimtsev | 2017-08-18 15:06:04 +0000 |
commit | 4610363d0b2ed6494338d486beb57127e6009d22 (patch) | |
tree | e6eede0fd0db40cfead97f9c91edba6410cf0662 /tests/org.eclipse.swt.tests | |
parent | f28f8cb0510c91905751bee0f128e0912d8324c8 (diff) | |
download | eclipse.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/org.eclipse.swt.tests')
-rw-r--r-- | tests/org.eclipse.swt.tests/BugSnippets/Bug500475_StyledText_NPE_on_selection_drag.java | 34 |
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(); + } +} |