mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
fix: unload plugins before unloading Dalamud to prevent crashes
This commit is contained in:
parent
de98b75336
commit
581cb506cc
4 changed files with 52 additions and 23 deletions
|
|
@ -351,6 +351,26 @@ namespace Dalamud
|
|||
this.finishUnloadSignal?.WaitOne();
|
||||
}
|
||||
|
||||
public void DisposePlugins()
|
||||
{
|
||||
// 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
|
||||
// a render call after it has been disposed, which can crash if it attempts to
|
||||
// use any resources that it freed in its own Dispose method
|
||||
this.InterfaceManager?.Dispose();
|
||||
|
||||
try
|
||||
{
|
||||
this.PluginManager.UnloadPlugins();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Plugin unload failed.");
|
||||
}
|
||||
|
||||
this.DalamudUi?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose Dalamud subsystems.
|
||||
/// </summary>
|
||||
|
|
@ -358,27 +378,6 @@ namespace Dalamud
|
|||
{
|
||||
try
|
||||
{
|
||||
// this must be done before unloading plugins, to prevent crashes due to errors
|
||||
// in plugin cleanup
|
||||
this.Framework.DispatchUpdateEvents = false;
|
||||
|
||||
// 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
|
||||
// a render call after it has been disposed, which can crash if it attempts to
|
||||
// use any resources that it freed in its own Dispose method
|
||||
this.InterfaceManager?.Dispose();
|
||||
|
||||
try
|
||||
{
|
||||
this.PluginManager.UnloadPlugins();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Plugin unload failed.");
|
||||
}
|
||||
|
||||
this.DalamudUi?.Dispose();
|
||||
|
||||
this.Framework?.Dispose();
|
||||
this.ClientState?.Dispose();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue