From a28f68c3a736d5d9e77a08b5e37c4a6a22a9791b Mon Sep 17 00:00:00 2001 From: Eliot the Cougar Date: Thu, 1 Oct 2026 14:55:30 +0300 Subject: [PATCH] Avoid reentrant log scrolling during Avalonia window dragging (#10271) --- v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs index 9e92fa83..4bb98a44 100644 --- a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs @@ -47,9 +47,14 @@ public partial class MsgView : ReactiveUserControl if (togScrollToEnd.IsChecked ?? true) { txtMsg.ScrollToEnd(); - Dispatcher.UIThread.Invoke(() => - txtMsg.ScrollTo(txtMsg.LineCount, 0, AvaloniaEdit.Rendering.VisualYPosition.TextBottom, txtMsg.Bounds.Height, 0), - DispatcherPriority.Background); + // Let layout finish without a nested dispatcher loop during a native window drag. + Dispatcher.UIThread.Post(() => + { + if (togScrollToEnd.IsChecked ?? true) + { + txtMsg.ScrollTo(txtMsg.LineCount, 0, AvaloniaEdit.Rendering.VisualYPosition.TextBottom, txtMsg.Bounds.Height, 0); + } + }, DispatcherPriority.Background); } }