Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316997

Summary: [Forms] FormText: IllegalArgumentException when copying empty selection - Fix in Eclipse 3.6.1
Product: [Eclipse Project] Platform Reporter: Konstantin Komissarchik <konstantin>
Component: User AssistanceAssignee: Chris Goldthorpe <cgold>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cgold
Version: 3.6   
Target Milestone: 3.6.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch cgold: iplog+

Description Konstantin Komissarchik CLA 2010-06-15 23:13:58 EDT
If the user goes to select text in FormText control and ends up with empty selection, the control doesn't always realize that no selection happened. It might take a few tries to reproduce this. I found that it helps to start selection and then move slightly down (not enough to go to the next line) before ending the selection. 

You can tell that the control thinks there is a selection present by the fact that Copy menu item is enabled. It might take a few tries to get into this state, but once you are there invoking Copy causes the following exception:

java.lang.IllegalArgumentException: Argument not valid
at org.eclipse.swt.SWT.error(SWT.java:3865)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.SWT.error(SWT.java:3770)
at org.eclipse.swt.dnd.DND.error(DND.java:282)
at org.eclipse.swt.dnd.DND.error(DND.java:228)
at org.eclipse.swt.dnd.Clipboard.setContents(Clipboard.java:480)
at org.eclipse.swt.dnd.Clipboard.setContents(Clipboard.java:411)
at org.eclipse.ui.forms.widgets.FormText.copy(FormText.java:1085)
at
org.eclipse.ui.forms.widgets.FormText$10.widgetSelected(FormText.java:920)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.ja
va:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:19
4)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Ec
lipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppL
auncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
Comment 1 Konstantin Komissarchik CLA 2010-06-15 23:16:56 EDT
Created attachment 172016 [details]
Patch

This patch adds an extra check for empty string right before a segment is added to selection data. Would be great to see this go into Helios SR1.
Comment 2 Chris Goldthorpe CLA 2010-06-18 17:14:38 EDT
I was able to reproduce while selecting in the introduction of the cheat sheet "Create a Hello World Application". I'll review your patch.
Comment 3 Chris Goldthorpe CLA 2010-06-18 17:29:05 EDT
The patch is good and looks completely safe. Targeting 3.6.1.
Comment 4 Chris Goldthorpe CLA 2010-06-25 17:16:22 EDT
Patch applied to HEAD, Fixed.
Comment 5 Chris Goldthorpe CLA 2010-06-25 17:17:18 EDT
That last comment should have been patch applied to 3.6 maintenance stream, Fixed for 3.6.1.