From 75035b3231b09daed09ace6e7e0d0f5bbe21a1a8 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sat, 26 Oct 2024 03:25:32 -0500 Subject: [PATCH] UI: Fix crash when using "delete all" button in mod manager. --- src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs index ddb6ab01c..df2ef266e 100644 --- a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs @@ -183,7 +183,7 @@ namespace Ryujinx.Ava.UI.ViewModels JsonHelper.SerializeToFile(_modJsonPath, modData, _serializerContext.ModMetadata); } - public void Delete(ModModel model) + public void Delete(ModModel model, bool removeFromList = true) { var isSubdir = true; var pathToDelete = model.Path; @@ -223,8 +223,11 @@ namespace Ryujinx.Ava.UI.ViewModels Logger.Info?.Print(LogClass.Application, $"Deleting mod at \"{pathToDelete}\""); Directory.Delete(pathToDelete, true); - Mods.Remove(model); - OnPropertyChanged(nameof(ModCount)); + if (removeFromList) + { + Mods.Remove(model); + OnPropertyChanged(nameof(ModCount)); + } Sort(); } @@ -314,7 +317,7 @@ namespace Ryujinx.Ava.UI.ViewModels public void DeleteAll() { - Mods.ForEach(Delete); + Mods.ForEach(it => Delete(it, false)); Mods.Clear(); OnPropertyChanged(nameof(ModCount)); Sort();