refactor: make all PluginInterface classes explicitly disposable

This commit is contained in:
goaaats 2022-01-08 03:00:56 +01:00
parent 33f230fa75
commit 2d90598b70
No known key found for this signature in database
GPG key ID: F18F057873895461
16 changed files with 43 additions and 29 deletions

View file

@ -19,6 +19,7 @@ using Dalamud.Plugin.Internal;
using Dalamud.Plugin.Ipc;
using Dalamud.Plugin.Ipc.Exceptions;
using Dalamud.Plugin.Ipc.Internal;
using Dalamud.Utility;
namespace Dalamud.Plugin
{
@ -383,9 +384,9 @@ namespace Dalamud.Plugin
/// <summary>
/// Unregister your plugin and dispose all references.
/// </summary>
public void Dispose()
void IDisposable.Dispose()
{
this.UiBuilder.Dispose();
this.UiBuilder.ExplicitDispose();
Service<ChatGui>.Get().RemoveChatLinkHandler(this.pluginName);
Service<Localization>.Get().LocalizationChanged -= this.OnLocalizationChanged;
Service<DalamudConfiguration>.Get().DalamudConfigurationSaved -= this.OnDalamudConfigurationSaved;

View file

@ -10,6 +10,7 @@ using Dalamud.Logging.Internal;
using Dalamud.Plugin.Internal.Exceptions;
using Dalamud.Plugin.Internal.Loader;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Utility;
namespace Dalamud.Plugin.Internal
{
@ -209,7 +210,7 @@ namespace Dalamud.Plugin.Internal
this.instance?.Dispose();
this.instance = null;
this.DalamudInterface?.Dispose();
this.DalamudInterface?.ExplicitDispose();
this.DalamudInterface = null;
this.pluginType = null;
@ -332,7 +333,7 @@ namespace Dalamud.Plugin.Internal
if (this.instance == null)
{
this.State = PluginState.LoadError;
this.DalamudInterface.Dispose();
this.DalamudInterface.ExplicitDispose();
Log.Error($"Error while loading {this.Name}, failed to bind and call the plugin constructor");
return;
}
@ -382,7 +383,7 @@ namespace Dalamud.Plugin.Internal
this.instance?.Dispose();
this.instance = null;
this.DalamudInterface?.Dispose();
this.DalamudInterface?.ExplicitDispose();
this.DalamudInterface = null;
this.pluginType = null;