Mono: Fix null dereference in EditorExportPlatformAndroid
We need to dispose the GodotSharpExport export plugin before the editor destroys EditorSettings. Otherwise, if the GC disposes it at a later time, EditorExportPlatformAndroid will be freed after EditorSettings already was, and its device polling thread will try to access the EditorSettings singleton, resulting in null dereferencing.
This commit is contained in:
parent
8b778f6234
commit
2a8294ff24
|
@ -26,6 +26,8 @@ namespace GodotTools
|
||||||
private MonoDevelopInstance monoDevelopInstance;
|
private MonoDevelopInstance monoDevelopInstance;
|
||||||
private MonoDevelopInstance visualStudioForMacInstance;
|
private MonoDevelopInstance visualStudioForMacInstance;
|
||||||
|
|
||||||
|
private WeakReference<GodotSharpExport> exportPluginWeak;
|
||||||
|
|
||||||
public MonoBottomPanel MonoBottomPanel { get; private set; }
|
public MonoBottomPanel MonoBottomPanel { get; private set; }
|
||||||
|
|
||||||
private bool CreateProjectSolution()
|
private bool CreateProjectSolution()
|
||||||
|
@ -513,11 +515,27 @@ namespace GodotTools
|
||||||
});
|
});
|
||||||
|
|
||||||
// Export plugin
|
// Export plugin
|
||||||
AddExportPlugin(new GodotSharpExport());
|
var exportPlugin = new GodotSharpExport();
|
||||||
|
AddExportPlugin(exportPlugin);
|
||||||
|
exportPluginWeak = new WeakReference<GodotSharpExport>(exportPlugin);
|
||||||
|
|
||||||
GodotSharpBuilds.Initialize();
|
GodotSharpBuilds.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
|
||||||
|
if (exportPluginWeak.TryGetTarget(out var exportPlugin))
|
||||||
|
{
|
||||||
|
// We need to dispose our export plugin before the editor destroys EditorSettings.
|
||||||
|
// Otherwise, if the GC disposes it at a later time, EditorExportPlatformAndroid
|
||||||
|
// will be freed after EditorSettings already was, and its device polling thread
|
||||||
|
// will try to access the EditorSettings singleton, resulting in null dereferencing.
|
||||||
|
exportPlugin.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnBeforeSerialize()
|
public void OnBeforeSerialize()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue