mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat: give dev plugins more leeway regarding unload errors
This commit is contained in:
parent
bb6109db45
commit
6ea7273e04
3 changed files with 26 additions and 8 deletions
|
|
@ -2222,7 +2222,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
||||||
|
|
||||||
StyleModelV1.DalamudStandard.Push();
|
StyleModelV1.DalamudStandard.Push();
|
||||||
|
|
||||||
if (plugin.State == PluginState.UnloadError)
|
if (plugin.State == PluginState.UnloadError && !plugin.IsDev)
|
||||||
{
|
{
|
||||||
ImGuiComponents.DisabledButton(FontAwesomeIcon.Frown);
|
ImGuiComponents.DisabledButton(FontAwesomeIcon.Frown);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,9 +138,9 @@ internal class LocalDevPlugin : LocalPlugin, IDisposable
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.State != PluginState.Loaded && this.State != PluginState.LoadError)
|
if (this.State != PluginState.Loaded && this.State != PluginState.LoadError && this.State != PluginState.UnloadError)
|
||||||
{
|
{
|
||||||
Log.Debug($"Skipping reload of {this.Name}, state ({this.State}) is not {PluginState.Loaded} nor {PluginState.LoadError}.");
|
Log.Debug($"Skipping reload of {this.Name}, state ({this.State}) is not {PluginState.Loaded}, {PluginState.LoadError} or {PluginState.UnloadError}.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,6 +148,12 @@ internal class LocalDevPlugin : LocalPlugin, IDisposable
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (this.State == PluginState.UnloadError)
|
||||||
|
{
|
||||||
|
Log.Warning($"{this.Manifest.Author}: TAKE CARE!!! You need to fix your unload error, and restart the game - your plugin might be in an inconsistent state.");
|
||||||
|
Log.Warning("Reloading anyway, as this is a dev plugin, but you might encounter unexpected results.");
|
||||||
|
}
|
||||||
|
|
||||||
await this.ReloadAsync();
|
await this.ReloadAsync();
|
||||||
notificationManager.AddNotification($"The DevPlugin '{this.Name} was reloaded successfully.", "Plugin reloaded!", NotificationType.Success);
|
notificationManager.AddNotification($"The DevPlugin '{this.Name} was reloaded successfully.", "Plugin reloaded!", NotificationType.Success);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Plugin.Internal.Exceptions;
|
using Dalamud.Plugin.Internal.Exceptions;
|
||||||
using Dalamud.Plugin.Internal.Loader;
|
using Dalamud.Plugin.Internal.Loader;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using Dalamud.Utility.Signatures;
|
|
||||||
|
|
||||||
namespace Dalamud.Plugin.Internal.Types;
|
namespace Dalamud.Plugin.Internal.Types;
|
||||||
|
|
||||||
|
|
@ -305,8 +304,13 @@ internal class LocalPlugin : IDisposable
|
||||||
throw new InvalidPluginOperationException(
|
throw new InvalidPluginOperationException(
|
||||||
$"Unable to load {this.Name}, load previously faulted, unload first");
|
$"Unable to load {this.Name}, load previously faulted, unload first");
|
||||||
case PluginState.UnloadError:
|
case PluginState.UnloadError:
|
||||||
throw new InvalidPluginOperationException(
|
if (!this.IsDev)
|
||||||
|
{
|
||||||
|
throw new InvalidPluginOperationException(
|
||||||
$"Unable to load {this.Name}, unload previously faulted, restart Dalamud");
|
$"Unable to load {this.Name}, unload previously faulted, restart Dalamud");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
case PluginState.Unloaded:
|
case PluginState.Unloaded:
|
||||||
break;
|
break;
|
||||||
case PluginState.Loading:
|
case PluginState.Loading:
|
||||||
|
|
@ -471,8 +475,13 @@ internal class LocalPlugin : IDisposable
|
||||||
case PluginState.Unloaded:
|
case PluginState.Unloaded:
|
||||||
throw new InvalidPluginOperationException($"Unable to unload {this.Name}, already unloaded");
|
throw new InvalidPluginOperationException($"Unable to unload {this.Name}, already unloaded");
|
||||||
case PluginState.UnloadError:
|
case PluginState.UnloadError:
|
||||||
throw new InvalidPluginOperationException(
|
if (!this.IsDev)
|
||||||
$"Unable to unload {this.Name}, unload previously faulted, restart Dalamud");
|
{
|
||||||
|
throw new InvalidPluginOperationException(
|
||||||
|
$"Unable to unload {this.Name}, unload previously faulted, restart Dalamud");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
case PluginState.Loaded:
|
case PluginState.Loaded:
|
||||||
case PluginState.LoadError:
|
case PluginState.LoadError:
|
||||||
break;
|
break;
|
||||||
|
|
@ -531,7 +540,10 @@ internal class LocalPlugin : IDisposable
|
||||||
/// <returns>A task.</returns>
|
/// <returns>A task.</returns>
|
||||||
public async Task ReloadAsync()
|
public async Task ReloadAsync()
|
||||||
{
|
{
|
||||||
await this.UnloadAsync(true);
|
// Don't unload if we're a dev plugin and have an unload error, this is a bad idea but whatever
|
||||||
|
if (this.IsDev && this.State != PluginState.UnloadError)
|
||||||
|
await this.UnloadAsync(true);
|
||||||
|
|
||||||
await this.LoadAsync(PluginLoadReason.Reload, true);
|
await this.LoadAsync(PluginLoadReason.Reload, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue