Skip to content

Clipboard issues with AvaloniaEdit 12.0.0 #597

@latop2604

Description

@latop2604

After upgrading to avalonia 12 I starded to get error related to clipboard.

The first issue is directly related to AvaloniaEdit control. After having some text added to the control. You can select a chunk of it, and hit ctrl+x. The chunk is then deleted. But the system clipboard does not contains the cutted data. If you hit ctrl+v just after, it will past data from a previous unrelated copy/cut action.

The issue happen on a simple Textbox. Write some text in it, sected a range, hit ctrl+x (or ctrl+c, then the app immediatly crash with the following exception.

Unhandled exception. System.Runtime.InteropServices.COMException (0x800401F0): CoInitialize n’a pas été appelé. (0x800401F0 (CO_E_NOTINITIALIZED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at Avalonia.Win32.ClipboardImpl.SetDataAsync(IAsyncDataTransfer dataTransfer)
   at Avalonia.Controls.TextBox.Cut()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__124_0(Object state)
   at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
   at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32DispatcherImpl.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
   at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.StartCore(String[] args)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
   at AvaloniaApplication1.Program.Main(String[] args) in d:\Dev\tmp\AvaloniaApplication1\Program.cs:line 12

Here is the repro app:

AvaloniaApplication1.zip

Avalonia version: 12.0.4
AvaloniaEdit: 12.0.0
OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions