mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
refactor: make all PluginInterface classes explicitly disposable
This commit is contained in:
parent
33f230fa75
commit
2d90598b70
16 changed files with 43 additions and 29 deletions
|
|
@ -93,7 +93,7 @@ namespace Dalamud.CorePlugin
|
||||||
|
|
||||||
this.windowSystem.RemoveAllWindows();
|
this.windowSystem.RemoveAllWindows();
|
||||||
|
|
||||||
this.Interface.Dispose();
|
this.Interface.ExplicitDispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Plugin.Internal;
|
using Dalamud.Plugin.Internal;
|
||||||
using Dalamud.Plugin.Ipc.Internal;
|
using Dalamud.Plugin.Ipc.Internal;
|
||||||
using Dalamud.Support;
|
using Dalamud.Support;
|
||||||
|
using Dalamud.Utility;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Core;
|
using Serilog.Core;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
@ -334,13 +335,13 @@ namespace Dalamud
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
Service<Framework>.GetNullable()?.Dispose();
|
Service<Framework>.GetNullable()?.ExplicitDispose();
|
||||||
Service<ClientState>.GetNullable()?.Dispose();
|
Service<ClientState>.GetNullable()?.ExplicitDispose();
|
||||||
|
|
||||||
this.unloadSignal?.Dispose();
|
this.unloadSignal?.Dispose();
|
||||||
|
|
||||||
Service<WinSockHandlers>.GetNullable()?.Dispose();
|
Service<WinSockHandlers>.GetNullable()?.Dispose();
|
||||||
Service<DataManager>.GetNullable()?.Dispose();
|
Service<DataManager>.GetNullable()?.ExplicitDispose();
|
||||||
Service<AntiDebug>.GetNullable()?.Dispose();
|
Service<AntiDebug>.GetNullable()?.Dispose();
|
||||||
Service<DalamudAtkTweaks>.GetNullable()?.Dispose();
|
Service<DalamudAtkTweaks>.GetNullable()?.Dispose();
|
||||||
Service<HookManager>.GetNullable()?.Dispose();
|
Service<HookManager>.GetNullable()?.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ namespace Dalamud.Data
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose this DataManager.
|
/// Dispose this DataManager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.luminaCancellationTokenSource.Cancel();
|
this.luminaCancellationTokenSource.Cancel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ using Dalamud.Game.Network.Internal;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
|
using Dalamud.Utility;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Game.ClientState
|
namespace Dalamud.Game.ClientState
|
||||||
|
|
@ -136,11 +137,11 @@ namespace Dalamud.Game.ClientState
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of managed and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.setupTerritoryTypeHook.Dispose();
|
this.setupTerritoryTypeHook.Dispose();
|
||||||
Service<Condition>.Get().Dispose();
|
Service<Condition>.Get().ExplicitDispose();
|
||||||
Service<GamepadState>.Get().Dispose();
|
Service<GamepadState>.Get().ExplicitDispose();
|
||||||
Service<Framework>.Get().Update -= this.FrameworkOnOnUpdateEvent;
|
Service<Framework>.Get().Update -= this.FrameworkOnOnUpdateEvent;
|
||||||
Service<NetworkHandlers>.Get().CfPop -= this.NetworkHandlersOnCfPop;
|
Service<NetworkHandlers>.Get().CfPop -= this.NetworkHandlersOnCfPop;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ namespace Dalamud.Game.ClientState.Conditions
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes this instance, alongside its hooks.
|
/// Disposes this instance, alongside its hooks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
this.Dispose(true);
|
this.Dispose(true);
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ namespace Dalamud.Game.ClientState.GamePad
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes this instance, alongside its hooks.
|
/// Disposes this instance, alongside its hooks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.Dispose(true);
|
this.Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
|
|
||||||
|
|
@ -135,10 +135,10 @@ namespace Dalamud.Game
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of managed and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
Service<GameGui>.GetNullable()?.Dispose();
|
Service<GameGui>.GetNullable()?.ExplicitDispose();
|
||||||
Service<GameNetwork>.GetNullable()?.Dispose();
|
Service<GameNetwork>.GetNullable()?.ExplicitDispose();
|
||||||
|
|
||||||
this.updateHook?.Disable();
|
this.updateHook?.Disable();
|
||||||
this.destroyHook?.Disable();
|
this.destroyHook?.Disable();
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace Dalamud.Game.Gui
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of managed and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.printMessageHook.Dispose();
|
this.printMessageHook.Dispose();
|
||||||
this.populateItemLinkHook.Dispose();
|
this.populateItemLinkHook.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -444,12 +444,12 @@ namespace Dalamud.Game.Gui
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disables the hooks and submodules of this module.
|
/// Disables the hooks and submodules of this module.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
Service<ChatGui>.Get().Dispose();
|
Service<ChatGui>.Get().ExplicitDispose();
|
||||||
Service<ToastGui>.Get().Dispose();
|
Service<ToastGui>.Get().ExplicitDispose();
|
||||||
Service<FlyTextGui>.Get().Dispose();
|
Service<FlyTextGui>.Get().ExplicitDispose();
|
||||||
Service<PartyFinderGui>.Get().Dispose();
|
Service<PartyFinderGui>.Get().ExplicitDispose();
|
||||||
this.setGlobalBgmHook.Dispose();
|
this.setGlobalBgmHook.Dispose();
|
||||||
this.handleItemHoverHook.Dispose();
|
this.handleItemHoverHook.Dispose();
|
||||||
this.handleItemOutHook.Dispose();
|
this.handleItemOutHook.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,9 @@ namespace Dalamud.Game.Gui.PartyFinder
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of m anaged and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.receiveListingHook.Dispose();
|
this.receiveListingHook.Dispose();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ namespace Dalamud.Game.Gui.Toast
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes of managed and unmanaged resources.
|
/// Disposes of managed and unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.showNormalToastHook.Dispose();
|
this.showNormalToastHook.Dispose();
|
||||||
this.showQuestToastHook.Dispose();
|
this.showQuestToastHook.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Dalamud.Game.Network
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of managed and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.processZonePacketDownHook.Dispose();
|
this.processZonePacketDownHook.Dispose();
|
||||||
this.processZonePacketUpHook.Dispose();
|
this.processZonePacketUpHook.Dispose();
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ namespace Dalamud.Interface
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unregister the UiBuilder. Do not call this in plugin code.
|
/// Unregister the UiBuilder. Do not call this in plugin code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
var interfaceManager = Service<InterfaceManager>.Get();
|
var interfaceManager = Service<InterfaceManager>.Get();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ using Dalamud.Plugin.Internal;
|
||||||
using Dalamud.Plugin.Ipc;
|
using Dalamud.Plugin.Ipc;
|
||||||
using Dalamud.Plugin.Ipc.Exceptions;
|
using Dalamud.Plugin.Ipc.Exceptions;
|
||||||
using Dalamud.Plugin.Ipc.Internal;
|
using Dalamud.Plugin.Ipc.Internal;
|
||||||
|
using Dalamud.Utility;
|
||||||
|
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
|
|
@ -383,9 +384,9 @@ namespace Dalamud.Plugin
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unregister your plugin and dispose all references.
|
/// Unregister your plugin and dispose all references.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
this.UiBuilder.Dispose();
|
this.UiBuilder.ExplicitDispose();
|
||||||
Service<ChatGui>.Get().RemoveChatLinkHandler(this.pluginName);
|
Service<ChatGui>.Get().RemoveChatLinkHandler(this.pluginName);
|
||||||
Service<Localization>.Get().LocalizationChanged -= this.OnLocalizationChanged;
|
Service<Localization>.Get().LocalizationChanged -= this.OnLocalizationChanged;
|
||||||
Service<DalamudConfiguration>.Get().DalamudConfigurationSaved -= this.OnDalamudConfigurationSaved;
|
Service<DalamudConfiguration>.Get().DalamudConfigurationSaved -= this.OnDalamudConfigurationSaved;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ 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.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
|
using Dalamud.Utility;
|
||||||
|
|
||||||
namespace Dalamud.Plugin.Internal
|
namespace Dalamud.Plugin.Internal
|
||||||
{
|
{
|
||||||
|
|
@ -209,7 +210,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
this.instance?.Dispose();
|
this.instance?.Dispose();
|
||||||
this.instance = null;
|
this.instance = null;
|
||||||
|
|
||||||
this.DalamudInterface?.Dispose();
|
this.DalamudInterface?.ExplicitDispose();
|
||||||
this.DalamudInterface = null;
|
this.DalamudInterface = null;
|
||||||
|
|
||||||
this.pluginType = null;
|
this.pluginType = null;
|
||||||
|
|
@ -332,7 +333,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
if (this.instance == null)
|
if (this.instance == null)
|
||||||
{
|
{
|
||||||
this.State = PluginState.LoadError;
|
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");
|
Log.Error($"Error while loading {this.Name}, failed to bind and call the plugin constructor");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +383,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
this.instance?.Dispose();
|
this.instance?.Dispose();
|
||||||
this.instance = null;
|
this.instance = null;
|
||||||
|
|
||||||
this.DalamudInterface?.Dispose();
|
this.DalamudInterface?.ExplicitDispose();
|
||||||
this.DalamudInterface = null;
|
this.DalamudInterface = null;
|
||||||
|
|
||||||
this.pluginType = null;
|
this.pluginType = null;
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,16 @@ namespace Dalamud.Utility
|
||||||
Process.Start(process);
|
Process.Start(process);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose this object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The object to dispose.</param>
|
||||||
|
/// <typeparam name="T">The type of object to dispose.</typeparam>
|
||||||
|
internal static void ExplicitDispose<T>(this T obj) where T : IDisposable
|
||||||
|
{
|
||||||
|
obj.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private static unsafe void ShowValue(ulong addr, IEnumerable<string> path, Type type, object value)
|
private static unsafe void ShowValue(ulong addr, IEnumerable<string> path, Type type, object value)
|
||||||
{
|
{
|
||||||
if (type.IsPointer)
|
if (type.IsPointer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue