Community
Participate
Working Groups
Build Identifier: 3.6.0 When I bind the text value of a Text(SWT.SEARCH | SWT.ICON_SEARCH SWT.ICON_CANCEL) with a search bean. When I click on the Text cancel icon, the 'verify Listener' of the SWTVetoableValueDecorator produce a StringIndexOutOfBoundsException : Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1931) 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:1258) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267) at org.eclipse.swt.widgets.Text.verifyText(Text.java:2199) at org.eclipse.swt.widgets.Text.gtk_delete_text(Text.java:1259) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1768) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4378) at org.eclipse.swt.internal.gtk.OS._gtk_editable_delete_text(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_editable_delete_text(OS.java:6509) at org.eclipse.swt.widgets.Text.gtk_icon_release(Text.java:1396) at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1769) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4378) at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8163) at org.eclipse.swt.widgets.Display.eventProc(Display.java:1239) at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method) at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2224) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3169) at org.eclipse.bug.BugSearchBinding$2.run(BugSearchBinding.java:130) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.bug.BugSearchBinding.main(BugSearchBinding.java:116) Reproducible: Always Steps to Reproduce: 1. Create a new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); 2. Bind SWTObservables.observeText(txtSearch, SWT.Modify) with a model observable 3. enter a value into the search text field 4. clear the search text field by clicking on the cancel icon.
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)