From d543b1a36e5a5fd5909df2ced3c4ee0a93aa5d49 Mon Sep 17 00:00:00 2001 From: jt Date: Tue, 16 Apr 2024 19:55:17 -0700 Subject: [PATCH 1/2] Fix some crashes on macOS & linux --- Avalonia.Gif/Avalonia.Gif.csproj | 2 +- CHANGELOG.md | 4 ++ ...tabilityMatrix.Avalonia.Diagnostics.csproj | 4 +- .../Extensions/DataObjectExtensions.cs | 14 +++++-- .../StabilityMatrix.Avalonia.csproj | 38 +++++++++---------- .../ControlThemes/BetterComboBoxStyles.axaml | 13 ++++--- .../Base/InferenceTabViewModelBase.cs | 5 ++- .../CheckpointManager/CheckpointFolder.cs | 3 +- .../Views/CheckpointsPage.axaml.cs | 9 +++-- .../Views/ConsoleOutputPage.axaml | 1 + .../StabilityMatrix.Core.csproj | 6 +-- .../StabilityMatrix.UITests.csproj | 2 +- 12 files changed, 60 insertions(+), 41 deletions(-) diff --git a/Avalonia.Gif/Avalonia.Gif.csproj b/Avalonia.Gif/Avalonia.Gif.csproj index dbf0defd..6a363589 100644 --- a/Avalonia.Gif/Avalonia.Gif.csproj +++ b/Avalonia.Gif/Avalonia.Gif.csproj @@ -10,7 +10,7 @@ true - + diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d49d7d5..455efd4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ### Fixed - Fixed more crashes when loading invalid connected model info files - Fixed pip installs not parsing comments properly +- Fixed crash when sending input to a process that isn't running +- Fixed [#576](https://github.com/LykosAI/StabilityMatrix/issues/576) - drag & drop crashes on macOS & Linux +- Fixed [#594](https://github.com/LykosAI/StabilityMatrix/issues/594) - missing thumbnails in Inference model selector +- Downgraded Avalonia back to 11.0.9 to fix [#589](https://github.com/LykosAI/StabilityMatrix/issues/589) and possibly other rendering issues ## v2.10.1 ### Added diff --git a/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj b/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj index 2fbf2fd4..72a57f69 100644 --- a/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj +++ b/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/StabilityMatrix.Avalonia/Extensions/DataObjectExtensions.cs b/StabilityMatrix.Avalonia/Extensions/DataObjectExtensions.cs index ef6a47f0..25993dd6 100644 --- a/StabilityMatrix.Avalonia/Extensions/DataObjectExtensions.cs +++ b/StabilityMatrix.Avalonia/Extensions/DataObjectExtensions.cs @@ -1,4 +1,5 @@ -using Avalonia.Input; +using System.Runtime.InteropServices; +using Avalonia.Input; namespace StabilityMatrix.Avalonia.Extensions; @@ -9,9 +10,16 @@ public static class DataObjectExtensions /// public static T? GetContext(this IDataObject dataObject) { - if (dataObject.Get("Context") is T context) + try { - return context; + if (dataObject.Get("Context") is T context) + { + return context; + } + } + catch (COMException) + { + return default; } return default; diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index b3fba009..cda7adcd 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -39,17 +39,17 @@ - - - - - - + + + + + + - + - - + + @@ -58,10 +58,10 @@ - - - - + + + + @@ -78,25 +78,25 @@ - + - + - + - - + + - + diff --git a/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml b/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml index c1274ef4..c5105328 100644 --- a/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml +++ b/StabilityMatrix.Avalonia/Styles/ControlThemes/BetterComboBoxStyles.axaml @@ -8,7 +8,8 @@ xmlns:sg="clr-namespace:SpacedGridControl.Avalonia;assembly=SpacedGridControl.Avalonia" xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:labs="clr-namespace:Avalonia.Labs.Controls;assembly=Avalonia.Labs.Controls" - xmlns:vendorLabs="clr-namespace:StabilityMatrix.Avalonia.Controls.VendorLabs"> + xmlns:vendorLabs="clr-namespace:StabilityMatrix.Avalonia.Controls.VendorLabs" + xmlns:converters="clr-namespace:StabilityMatrix.Avalonia.Converters"> @@ -29,7 +30,9 @@ - + + + @@ -220,7 +223,7 @@ Height="36" CornerRadius="60" RenderOptions.BitmapInterpolationMode="HighQuality" - Source="{Binding Local.PreviewImageFullPathGlobal}" + Source="{Binding Local.PreviewImageFullPathGlobal, Converter={StaticResource FileUriConverter}}" Stretch="UniformToFill"> diff --git a/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs b/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs index 57e6bf47..30fd84ff 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs @@ -18,6 +18,7 @@ using FluentAvalonia.UI.Media.Animation; using Microsoft.Extensions.DependencyInjection; using NLog; using StabilityMatrix.Avalonia.Animations; +using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Models.Inference; using StabilityMatrix.Avalonia.Services; @@ -249,7 +250,7 @@ public abstract partial class InferenceTabViewModelBase // 1. Context drop for LocalImageFile if (e.Data.GetDataFormats().Contains("Context")) { - if (e.Data.Get("Context") is LocalImageFile imageFile) + if (e.Data.GetContext() is { } imageFile) { e.Handled = true; return; @@ -274,7 +275,7 @@ public abstract partial class InferenceTabViewModelBase // 1. Context drop for LocalImageFile if (e.Data.GetDataFormats().Contains("Context")) { - if (e.Data.Get("Context") is LocalImageFile imageFile) + if (e.Data.GetContext() is { } imageFile) { e.Handled = true; diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs index 5f23e3fc..51ad4025 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs @@ -15,6 +15,7 @@ using CommunityToolkit.Mvvm.Input; using DynamicData; using DynamicData.Binding; using FluentAvalonia.UI.Controls; +using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Core.Attributes; @@ -279,7 +280,7 @@ public partial class CheckpointFolder : ViewModelBase var paths = files.Select(f => f.Path.LocalPath).ToArray(); await ImportFilesAsync(paths, settingsManager.Settings.IsImportAsConnected); } - else if (e.Data.Get("Context") is CheckpointFile file) + else if (e.Data.GetContext() is { } file) { await MoveBetweenFolders(file); } diff --git a/StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml.cs b/StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml.cs index e95b45f4..dda5cd9c 100644 --- a/StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml.cs +++ b/StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml.cs @@ -6,6 +6,7 @@ using Avalonia.Markup.Xaml; using Avalonia.VisualTree; using DynamicData.Binding; using StabilityMatrix.Avalonia.Controls; +using StabilityMatrix.Avalonia.Extensions; using StabilityMatrix.Avalonia.ViewModels; using StabilityMatrix.Avalonia.ViewModels.CheckpointManager; using StabilityMatrix.Core.Attributes; @@ -68,7 +69,7 @@ public partial class CheckpointsPage : UserControlBase { case CheckpointFolder folder: { - if (e.Data.Get("Context") is not CheckpointFile file) + if (e.Data.GetContext() is not { } file) { await folder.OnDrop(e); break; @@ -83,7 +84,7 @@ public partial class CheckpointsPage : UserControlBase } case CheckpointFile file: { - if (e.Data.Get("Context") is not CheckpointFile dragFile) + if (e.Data.GetContext() is not { } dragFile) { await file.ParentFolder.OnDrop(e); break; @@ -132,7 +133,7 @@ public partial class CheckpointsPage : UserControlBase case CheckpointFolder folder: { folder.IsExpanded = true; - if (e.Data.Get("Context") is not CheckpointFile file) + if (e.Data.GetContext() is not { } file) { folder.IsCurrentDragTarget = true; break; @@ -144,7 +145,7 @@ public partial class CheckpointsPage : UserControlBase } case CheckpointFile file: { - if (e.Data.Get("Context") is not CheckpointFile dragFile) + if (e.Data.GetContext() is not { } dragFile) { file.ParentFolder.IsCurrentDragTarget = true; break; diff --git a/StabilityMatrix.Avalonia/Views/ConsoleOutputPage.axaml b/StabilityMatrix.Avalonia/Views/ConsoleOutputPage.axaml index d44b44e6..7fa19f89 100644 --- a/StabilityMatrix.Avalonia/Views/ConsoleOutputPage.axaml +++ b/StabilityMatrix.Avalonia/Views/ConsoleOutputPage.axaml @@ -89,6 +89,7 @@ Classes="accent" IsDefault="True" Content="{x:Static lang:Resources.Action_Send}" + IsEnabled="{Binding IsRunning}" Command="{Binding SendToConsoleCommand}"/> diff --git a/StabilityMatrix.Core/StabilityMatrix.Core.csproj b/StabilityMatrix.Core/StabilityMatrix.Core.csproj index 5005b1bd..76fa5624 100644 --- a/StabilityMatrix.Core/StabilityMatrix.Core.csproj +++ b/StabilityMatrix.Core/StabilityMatrix.Core.csproj @@ -27,7 +27,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -53,7 +53,7 @@ - + diff --git a/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj b/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj index eb592e08..66d3a9ee 100644 --- a/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj +++ b/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj @@ -15,7 +15,7 @@ - + From 047d973b11bbbd3798ea647d8a851f08d40232d7 Mon Sep 17 00:00:00 2001 From: JT Date: Tue, 16 Apr 2024 20:34:41 -0700 Subject: [PATCH 2/2] use AvaloniaVersion variable --- Avalonia.Gif/Avalonia.Gif.csproj | 2 +- Directory.Build.props | 5 +++++ .../StabilityMatrix.Avalonia.Diagnostics.csproj | 4 ++-- .../StabilityMatrix.Avalonia.csproj | 12 ++++++------ .../StabilityMatrix.UITests.csproj | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 Directory.Build.props diff --git a/Avalonia.Gif/Avalonia.Gif.csproj b/Avalonia.Gif/Avalonia.Gif.csproj index 6a363589..48a8f949 100644 --- a/Avalonia.Gif/Avalonia.Gif.csproj +++ b/Avalonia.Gif/Avalonia.Gif.csproj @@ -10,7 +10,7 @@ true - + diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..e059bd8f --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + 11.0.9 + + diff --git a/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj b/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj index 72a57f69..7d0762ac 100644 --- a/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj +++ b/StabilityMatrix.Avalonia.Diagnostics/StabilityMatrix.Avalonia.Diagnostics.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index cda7adcd..096e08c9 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -39,14 +39,14 @@ - - + + - - - + + + - + diff --git a/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj b/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj index 66d3a9ee..2ebeb2e8 100644 --- a/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj +++ b/StabilityMatrix.UITests/StabilityMatrix.UITests.csproj @@ -15,7 +15,7 @@ - +