Skip to content

Commit

Permalink
UI: Fix crash when using "delete all" button in mod manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Oct 26, 2024
1 parent 9a1bdaa commit 75035b3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void Save()
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;
Expand Down Expand Up @@ -223,8 +223,11 @@ await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetD
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();
}

Expand Down Expand Up @@ -314,7 +317,7 @@ public async void Add()

public void DeleteAll()
{
Mods.ForEach(Delete);
Mods.ForEach(it => Delete(it, false));
Mods.Clear();
OnPropertyChanged(nameof(ModCount));
Sort();
Expand Down

0 comments on commit 75035b3

Please sign in to comment.