| Summary: | [DataBinding] StringIndexOutOfBoundsException exception when clearing a Text with SWT.SEARCH | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Igor Laborie <ilaborie> | ||||||||||||
| Component: | SWT | Assignee: | Felipe Heidrich <eclipse.felipe> | ||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||||
| Severity: | normal | ||||||||||||||
| Priority: | P3 | CC: | dany.eudes, eclipse.felipe, grant_gayed, mallo.ovidio, marcolopespt, Silenio_Quarti | ||||||||||||
| Version: | 3.6 | Flags: | Silenio_Quarti:
review+
|
||||||||||||
| Target Milestone: | 3.6.1 | ||||||||||||||
| Hardware: | PC | ||||||||||||||
| OS: | Linux | ||||||||||||||
| Whiteboard: | |||||||||||||||
| Attachments: |
|
||||||||||||||
|
Description
Igor Laborie
Created attachment 173348 [details]
A test project
Created attachment 173350 [details]
A Workaround
I might be a SWT bug ?
Into the verify listener of SWTVetoableValueDecorator the end value of event object is -1.
This patch could be a workaround.
This appears to be an swt bug, so moving there. To see the root cause: - run ControlExample, go to the Text tab - listen for Verify events - select styles SWT.SEARCH, SWT.ICON_CANCEL and SWT.ICON_SEARCH - press the Text's Cancel button to clear its content - note that that output Verify event has end = -1, rather than the expected value of 58 Created attachment 175316 [details]
patch
Looks like a bug in GTK, calling gtk_editable_delete_text(handle, 0, -1) causes gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) where end_pos == -1.
It works for me, so maybe this only happens in some version of GTK.
What version are you running ?
Please try the attached patch and let me know if it fixes the problem for you.
Yes the patch fixes this case. I'm using SSQ's Ubuntu 10. (In reply to comment #4) > Created an attachment (id=175316) [details] > patch > > Looks like a bug in GTK, calling gtk_editable_delete_text(handle, 0, -1) causes > gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ > end_pos) where end_pos == -1. > > It works for me, so maybe this only happens in some version of GTK. > What version are you running ? > > Please try the attached patch and let me know if it fixes the problem for you. The patch fix the problem. I'm also using Ubuntu (10.4) with gtk 2.20.1 Fixed in HEAD Silenio, 3.6.1 ? Note: it happens to newer version of GTK. Created attachment 175407 [details]
patch for Text/Combo/Spinner
This patch fixes the problem for other widgets as well. The fix is in the callback side because it can happen in other cases.
+1 to release to 3.6.1 Created attachment 175411 [details]
patch for 3.6.1
Same patch as HEAD (line number is different)
Fixed in 3.6.1 > 20100728
I'm using Nebula IntegerFormatter from Nebula FormattedText widget with databinding and got similar StringIndexOutOfBoundsException. The control has SWT.RIGHT style. The exception throws after a) select all control characters (CTRL-A) and hit DEL; or b) with cursor at last right position, hit BACKSPACE. [Windows Vista] !MESSAGE Unhandled event loop exception !STACK 0 java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1937) at java.lang.String.substring(String.java:1904) at org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator$1.handleEvent(SWTVetoableValueDecorator.java:38) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062) at org.eclipse.swt.widgets.Text.verifyText(Text.java:2066) at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1517) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1099) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1508) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4268) at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2175) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4160) at org.eclipse.swt.widgets.Text.windowProc(Text.java:2170) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2459) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3655) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) Please try the 3.6.1 build or 3.7 M2. If the bug still happens with these builds, reopen this bug. (In reply to comment #12) > Please try the 3.6.1 build or 3.7 M2. If the bug still happens with these > builds, reopen this bug. Thank you for your reply. I'll follow your suggestion. Could you point me where I could download 3.6.1 build. I cannot see it in http://download.eclipse.org/eclipse/downloads. I see just the 3.6.x Stream Build. Is stream build stable for a production enviroment? Eclipse 3.6.1 has not been declared yet, but it is going to be based on this build (RC4): http://download.eclipse.org/eclipse/downloads/drops/M20100909-0800/index.php It should be out by the end of September: http://www.eclipse.org/eclipse/development/plans/freeze_plan_3_6_1.php (In reply to comment #14) Thank you so much, Mr. Quarti! *** Bug 301871 has been marked as a duplicate of this bug. *** Still getting this error on latest INDIGO release M6a (Build id: 20110319-2305) (i use "org.eclipse.nebula.widgets" NumberFormatter, that woked pretty well in previous versions of Eclipse). !ENTRY org.eclipse.ui 4 0 2011-04-15 18:34:09.359 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) at java.lang.String.substring(Unknown Source) at org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator$1.handleEvent(SWTVetoableValueDecorator.java:38) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062) at org.eclipse.swt.widgets.Text.verifyText(Text.java:2139) at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1543) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1509) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4623) at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2248) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4511) at org.eclipse.swt.widgets.Text.windowProc(Text.java:2243) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4957) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2525) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3737) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at rcpcolibri.Application.start(Application.java:43) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) 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:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) |