From 13a645a462cc674d609816e35eaf9ff83c668044 Mon Sep 17 00:00:00 2001 From: Emilia <emilia@jumpsca.re> Date: Sat, 22 Mar 2025 11:19:18 +0200 Subject: [PATCH] Fix Docking UI and ScrollToEnd race condition crash --- .idea/.idea.Blacklight/.idea/avalonia.xml | 1 + Blacklight.Desktop/Blacklight.Desktop.csproj | 2 +- Blacklight/Blacklight.csproj | 2 +- Blacklight/Util/ScrollToEndBehavior.cs | 12 ++++++------ Blacklight/ViewModels/ClientViewModel.cs | 2 +- Lightquark.NET/Lightquark.NET.csproj | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.idea/.idea.Blacklight/.idea/avalonia.xml b/.idea/.idea.Blacklight/.idea/avalonia.xml index b0754ad..c64d48f 100644 --- a/.idea/.idea.Blacklight/.idea/avalonia.xml +++ b/.idea/.idea.Blacklight/.idea/avalonia.xml @@ -8,6 +8,7 @@ <entry key="Blacklight/ErrorWindow.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/App.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/ClientView.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> + <entry key="Blacklight/Views/Dialogs/CreateChannelView.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/Documents/DocumentView.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/ErrorBoundary.axaml" value="Blacklight.Desktop/Blacklight.Desktop.csproj" /> <entry key="Blacklight/Views/LoadingView.axaml" value="Blacklight/Blacklight.csproj" /> diff --git a/Blacklight.Desktop/Blacklight.Desktop.csproj b/Blacklight.Desktop/Blacklight.Desktop.csproj index c9947ee..329c128 100644 --- a/Blacklight.Desktop/Blacklight.Desktop.csproj +++ b/Blacklight.Desktop/Blacklight.Desktop.csproj @@ -1,4 +1,4 @@ -<Project Sdk="Microsoft.NET.Sdk"> +<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> diff --git a/Blacklight/Blacklight.csproj b/Blacklight/Blacklight.csproj index d7c3af5..ee993e1 100644 --- a/Blacklight/Blacklight.csproj +++ b/Blacklight/Blacklight.csproj @@ -1,4 +1,4 @@ -<Project Sdk="Microsoft.NET.Sdk"> +<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net9.0</TargetFramework> <Nullable>enable</Nullable> diff --git a/Blacklight/Util/ScrollToEndBehavior.cs b/Blacklight/Util/ScrollToEndBehavior.cs index 4b6dffa..f3425d6 100644 --- a/Blacklight/Util/ScrollToEndBehavior.cs +++ b/Blacklight/Util/ScrollToEndBehavior.cs @@ -28,13 +28,13 @@ public class ScrollToEndBehavior : Behavior<ScrollViewer> private void ScrollNow(bool shouldScroll) { - Log.Information("I should scroll maybe? {ShouldScroll}, {Other}", shouldScroll, AssociatedObject != null); - if (shouldScroll && AssociatedObject != null) + Log.Debug("I should scroll maybe? {ShouldScroll}, {Other}", shouldScroll, AssociatedObject != null); + Dispatcher.UIThread.Post(() => { - Dispatcher.UIThread.Post(() => + if (shouldScroll && AssociatedObject != null) { - AssociatedObject.ScrollToEnd(); - }); - } + AssociatedObject.ScrollToEnd(); + } + }); } } diff --git a/Blacklight/ViewModels/ClientViewModel.cs b/Blacklight/ViewModels/ClientViewModel.cs index b1d4d22..bb9b62e 100644 --- a/Blacklight/ViewModels/ClientViewModel.cs +++ b/Blacklight/ViewModels/ClientViewModel.cs @@ -44,6 +44,7 @@ public class ClientViewModel : ViewModelBase Client = client; DebugFactoryEvents(_factory); + Layout = _factory?.CreateLayout(); if (Layout is { }) { _factory?.InitLayout(Layout); @@ -52,7 +53,6 @@ public class ClientViewModel : ViewModelBase root.Navigate.Execute("Home"); } } - Layout = _factory?.CreateLayout(); NewLayout = new RelayCommand(ResetLayout); Logout = new RelayCommand(LogoutNow); diff --git a/Lightquark.NET/Lightquark.NET.csproj b/Lightquark.NET/Lightquark.NET.csproj index af2f5cd..0f98b0a 100644 --- a/Lightquark.NET/Lightquark.NET.csproj +++ b/Lightquark.NET/Lightquark.NET.csproj @@ -8,7 +8,7 @@ <ItemGroup> <PackageReference Include="AutoMapper" Version="14.0.0" /> - <PackageReference Include="Avalonia" Version="11.2.5" /> + <PackageReference Include="Avalonia" Version="11.1.3" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> <PackageReference Include="Lightquark.Types" Version="2024.9.15.139" /> <PackageReference Include="Markdig" Version="0.40.0" /> -- GitLab