mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
refactor: move dispose logic out of entrypoint
This commit is contained in:
parent
8976bfec3f
commit
b7fd154b91
2 changed files with 10 additions and 5 deletions
|
|
@ -31,6 +31,8 @@ namespace Dalamud
|
||||||
|
|
||||||
private readonly string baseDirectory;
|
private readonly string baseDirectory;
|
||||||
|
|
||||||
|
private bool hasDisposedPlugins = false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -351,8 +353,13 @@ namespace Dalamud
|
||||||
this.finishUnloadSignal?.WaitOne();
|
this.finishUnloadSignal?.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose subsystems related to plugin handling.
|
||||||
|
/// </summary>
|
||||||
public void DisposePlugins()
|
public void DisposePlugins()
|
||||||
{
|
{
|
||||||
|
this.hasDisposedPlugins = true;
|
||||||
|
|
||||||
// this must be done before unloading plugins, or it can cause a race condition
|
// this must be done before unloading plugins, or it can cause a race condition
|
||||||
// due to rendering happening on another thread, where a plugin might receive
|
// due to rendering happening on another thread, where a plugin might receive
|
||||||
// a render call after it has been disposed, which can crash if it attempts to
|
// a render call after it has been disposed, which can crash if it attempts to
|
||||||
|
|
@ -378,6 +385,9 @@ namespace Dalamud
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!this.hasDisposedPlugins)
|
||||||
|
this.DisposePlugins();
|
||||||
|
|
||||||
this.Framework?.Dispose();
|
this.Framework?.Dispose();
|
||||||
this.ClientState?.Dispose();
|
this.ClientState?.Dispose();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,6 @@ namespace Dalamud
|
||||||
// Run session
|
// Run session
|
||||||
dalamud.Start();
|
dalamud.Start();
|
||||||
dalamud.WaitForUnload();
|
dalamud.WaitForUnload();
|
||||||
if (dalamud.Framework.DispatchUpdateEvents)
|
|
||||||
{
|
|
||||||
dalamud.DisposePlugins();
|
|
||||||
Thread.Sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
dalamud.Dispose();
|
dalamud.Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue