From 1e40a930a91a8775ec8a4f11a6154e904f7e0d2d Mon Sep 17 00:00:00 2001
From: Aireil <33433913+Aireil@users.noreply.github.com>
Date: Wed, 17 Aug 2022 22:13:31 +0200
Subject: [PATCH] fix: plugin config deletion context menu (#955)
---
.../PluginInstaller/PluginInstallerWindow.cs | 4 ++--
Dalamud/Plugin/Internal/PluginManager.cs | 14 +++++++++-----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
index b658d3304..003c26105 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
@@ -2631,9 +2631,9 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
public static string PluginContext_HidePlugin => Loc.Localize("InstallerHidePlugin", "Hide from installer");
- public static string PluginContext_DeletePluginConfig => Loc.Localize("InstallerDeletePluginConfig", "Reset plugin");
+ public static string PluginContext_DeletePluginConfig => Loc.Localize("InstallerDeletePluginConfig", "Reset plugin configuration");
- public static string PluginContext_DeletePluginConfigReload => Loc.Localize("InstallerDeletePluginConfigReload", "Reset plugin settings & reload");
+ public static string PluginContext_DeletePluginConfigReload => Loc.Localize("InstallerDeletePluginConfigReload", "Reset plugin configuration and reload");
#endregion
diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs
index 8051cc081..2634cbd30 100644
--- a/Dalamud/Plugin/Internal/PluginManager.cs
+++ b/Dalamud/Plugin/Internal/PluginManager.cs
@@ -1128,17 +1128,18 @@ internal partial class PluginManager : IDisposable, IServiceType
}
///
- /// Unload the plugin, delete its configuration, and reload it.
+ /// Delete the plugin configuration, unload/reload it if loaded.
///
/// The plugin.
/// Throws if the plugin is still loading/unloading.
/// The task.
public async Task DeleteConfigurationAsync(LocalPlugin plugin)
{
- if (plugin.State == PluginState.Loading || plugin.State == PluginState.Unloaded)
+ if (plugin.State is PluginState.Loading or PluginState.Unloading)
throw new Exception("Cannot delete configuration for a loading/unloading plugin");
- if (plugin.IsLoaded)
+ var isReloading = plugin.IsLoaded;
+ if (isReloading)
await plugin.UnloadAsync();
for (var waitUntil = Environment.TickCount64 + 1000; Environment.TickCount64 < waitUntil;)
@@ -1154,8 +1155,11 @@ internal partial class PluginManager : IDisposable, IServiceType
}
}
- // Let's indicate "installer" here since this is supposed to be a fresh install
- await plugin.LoadAsync(PluginLoadReason.Installer);
+ if (isReloading)
+ {
+ // Let's indicate "installer" here since this is supposed to be a fresh install
+ await plugin.LoadAsync(PluginLoadReason.Installer);
+ }
}
///