mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-19 04:37:09 +00:00
UI: Fix crash when using "delete all" button in mod manager.
This commit is contained in:
parent
69ba77d6ee
commit
05058e1cf8
1 changed files with 8 additions and 8 deletions
|
|
@ -4,6 +4,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
|
using Gommon;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Models;
|
using Ryujinx.Ava.UI.Models;
|
||||||
|
|
@ -182,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;
|
||||||
|
|
@ -222,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,11 +317,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
public void DeleteAll()
|
public void DeleteAll()
|
||||||
{
|
{
|
||||||
foreach (var mod in Mods)
|
Mods.ForEach(it => Delete(it, false));
|
||||||
{
|
|
||||||
Delete(mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
Mods.Clear();
|
Mods.Clear();
|
||||||
OnPropertyChanged(nameof(ModCount));
|
OnPropertyChanged(nameof(ModCount));
|
||||||
Sort();
|
Sort();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue