mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
remove plugins from deleting profile synchronously
This commit is contained in:
parent
2ed215b74b
commit
7fe004c875
2 changed files with 8 additions and 4 deletions
|
|
@ -243,7 +243,9 @@ internal class ProfileManagerWidget
|
|||
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Trash))
|
||||
{
|
||||
Task.Run(() => profman.DeleteProfile(profile))
|
||||
// DeleteProfile() is sync, it doesn't apply and we are modifying the plugins collection. Will throw below when iterating
|
||||
profman.DeleteProfile(profile);
|
||||
Task.Run(() => profman.ApplyAllWantStates())
|
||||
.ContinueWith(t =>
|
||||
{
|
||||
this.Reset();
|
||||
|
|
|
|||
|
|
@ -232,13 +232,16 @@ internal class ProfileManager : IServiceType
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a profile and re-apply all profiles.
|
||||
/// Delete a profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// You should definitely apply states after this. It doesn't do it for you.
|
||||
/// </remarks>
|
||||
/// <param name="profile">The profile to delete.</param>
|
||||
public void DeleteProfile(Profile profile)
|
||||
{
|
||||
// We need to remove all plugins from the profile first, so that they are re-added to the default profile if needed
|
||||
foreach (var plugin in profile.Plugins)
|
||||
foreach (var plugin in profile.Plugins.ToArray())
|
||||
{
|
||||
profile.Remove(plugin.InternalName, false);
|
||||
}
|
||||
|
|
@ -246,7 +249,6 @@ internal class ProfileManager : IServiceType
|
|||
Debug.Assert(this.config.SavedProfiles!.Remove(profile.Model), "this.config.SavedProfiles!.Remove(profile.Model)");
|
||||
Debug.Assert(this.profiles.Remove(profile), "this.profiles.Remove(profile)");
|
||||
|
||||
this.ApplyAllWantStates();
|
||||
this.config.QueueSave();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue