Avalonia: [Textbox] Bug async, set, focus

Created on 11 Sep 2016  路  3Comments  路  Source: AvaloniaUI/Avalonia

Hello, this is a big bug.

1 - write text in textbox
2 - get async text (textbox is focus)
3 - set text with any characters

and try to write a text but the app crash with this exception :

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in Avalonia.Interactivity.dll
Additional information: _Index and length must refer to a location in the chain._

Stacktrace :

脿 System.String.Substring(Int32 startIndex, Int32 length)
   脿 Avalonia.Controls.TextBox.HandleTextInput(String input)
   脿 Avalonia.Controls.TextBox.OnTextInput(TextInputEventArgs e)
   脿 Avalonia.Interactivity.RoutedEvent`1.<>c__DisplayClass1_0`1.<AddClassHandler>b__0(Object sender, RoutedEventArgs e)
--- Fin de la trace de la pile 脿 partir de l'emplacement pr茅c茅dent au niveau duquel l'exception a 茅t茅 lev茅e ---
   脿 Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass25_0.<AddClassHandler>b__0(Tuple`2 args)
   脿 System.Reactive.AnonymousObserver`1.OnNextCore(T value)
   脿 System.Reactive.ObserverBase`1.OnNext(T value)
   脿 System.Reactive.Subjects.Subject`1.OnNext(T value)
   脿 Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   脿 Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   脿 Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   脿 Avalonia.Input.KeyboardDevice.ProcessRawEvent(RawInputEventArgs e)
   脿 System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
   脿 System.Reactive.Linq.ObservableImpl.Where`1._.OnNext(TSource value)
   脿 System.Reactive.Linq.ObservableImpl.OfType`2._.OnNext(TSource value)
   脿 System.Reactive.Observer`1.OnNext(T value)
   脿 System.Reactive.Subjects.Subject`1.OnNext(T value)
   脿 Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
   脿 Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e)
   脿 Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   脿 Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   脿 Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   脿 Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   脿 Avalonia.Application.Run(ICloseable closable)
   脿 Avalonia.Controls.AppBuilder.Start[TMainWindow]()
   脿 AvaloniaApp.App.Main(String[] args) dans C:\Users\*******\AvaloniaApp\AvaloniaApp\App.xaml.cs:ligne 24
   脿 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   脿 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   脿 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   脿 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   脿 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   脿 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   脿 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   脿 System.Threading.ThreadHelper.ThreadStart()

Exemple code :
http://paste.awesom.eu/gd9W

bug

Most helpful comment

I'm not able to repro with your exact repro steps. However I am able to get the same stack via the following (using your sample code)

1) type at least 4 chars into the textbox
2) click "set"
3) type another char into the textbox

The problem is that CaretIndex is not changing when text is set programatically.

All 3 comments

I'm not able to repro with your exact repro steps. However I am able to get the same stack via the following (using your sample code)

1) type at least 4 chars into the textbox
2) click "set"
3) type another char into the textbox

The problem is that CaretIndex is not changing when text is set programatically.

Any solution ?

@the57200 could you try #788 and see if that fixes the problem for you?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

x2bool picture x2bool  路  4Comments

khoshroomahdi picture khoshroomahdi  路  4Comments

danwalmsley picture danwalmsley  路  4Comments

JonathaN7Shepard picture JonathaN7Shepard  路  4Comments

maxkatz6 picture maxkatz6  路  3Comments