dispose characters on unloading plugin

This commit is contained in:
rootdarkarchon
2023-12-26 14:36:54 +01:00
committed by Loporrit
parent 1c8267dd93
commit 06f6b75e72
5 changed files with 17 additions and 16 deletions

View File

@@ -46,7 +46,7 @@ public sealed class Plugin : IDalamudPlugin
public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData,
IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
IGameGui gameGui, IDtrBar dtrBar, IToastGui toastGui, IPluginLog pluginLog, ITargetManager targetManager)
IGameGui gameGui, IDtrBar dtrBar, IToastGui toastGui, IPluginLog pluginLog, ITargetManager targetManager, IGameLifecycle addonLifecycle)
{
Plugin.Self = this;
_hostBuilderRunTask = new HostBuilder()
@@ -78,7 +78,10 @@ public sealed class Plugin : IDalamudPlugin
collection.AddSingleton<MareProfileManager>();
collection.AddSingleton<GameObjectHandlerFactory>();
collection.AddSingleton<FileDownloadManagerFactory>();
collection.AddSingleton<PairHandlerFactory>();
collection.AddSingleton((s) => new PairHandlerFactory(s.GetRequiredService<ILoggerFactory>(), s.GetRequiredService<GameObjectHandlerFactory>(),
s.GetRequiredService<IpcManager>(), s.GetRequiredService<FileDownloadManagerFactory>(), s.GetRequiredService<DalamudUtilService>(),
s.GetRequiredService<PluginWarningNotificationService>(), CancellationTokenSource.CreateLinkedTokenSource(addonLifecycle.GameShuttingDownToken, addonLifecycle.DalamudUnloadingToken).Token,
s.GetRequiredService<FileCacheManager>(), s.GetRequiredService<MareMediator>()));
collection.AddSingleton<PairFactory>();
collection.AddSingleton<CharacterAnalyzer>();
collection.AddSingleton<TokenProvider>();
@@ -152,6 +155,6 @@ public sealed class Plugin : IDalamudPlugin
{
_pluginCts.Cancel();
_pluginCts.Dispose();
Task.WaitAny(_hostBuilderRunTask);
_hostBuilderRunTask.Wait();
}
}
}