0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 23:55:47 +00:00

UI: Fix crash when using "delete all" button in mod manager.

This commit is contained in:
Evan Husted 2024-10-26 03:25:32 -05:00
parent 9a1bdaae16
commit 75035b3231

View file

@ -183,7 +183,7 @@ namespace Ryujinx.Ava.UI.ViewModels
JsonHelper.SerializeToFile(_modJsonPath, modData, _serializerContext.ModMetadata); JsonHelper.SerializeToFile(_modJsonPath, modData, _serializerContext.ModMetadata);
} }
public void Delete(ModModel model) public void Delete(ModModel model, bool removeFromList = true)
{ {
var isSubdir = true; var isSubdir = true;
var pathToDelete = model.Path; var pathToDelete = model.Path;
@ -223,8 +223,11 @@ namespace Ryujinx.Ava.UI.ViewModels
Logger.Info?.Print(LogClass.Application, $"Deleting mod at \"{pathToDelete}\""); Logger.Info?.Print(LogClass.Application, $"Deleting mod at \"{pathToDelete}\"");
Directory.Delete(pathToDelete, true); Directory.Delete(pathToDelete, true);
if (removeFromList)
{
Mods.Remove(model); Mods.Remove(model);
OnPropertyChanged(nameof(ModCount)); OnPropertyChanged(nameof(ModCount));
}
Sort(); Sort();
} }
@ -314,7 +317,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public void DeleteAll() public void DeleteAll()
{ {
Mods.ForEach(Delete); Mods.ForEach(it => Delete(it, false));
Mods.Clear(); Mods.Clear();
OnPropertyChanged(nameof(ModCount)); OnPropertyChanged(nameof(ModCount));
Sort(); Sort();