1
0
Fork 0

Fix for reset crash:

https://sourceforge.net/p/flightgear/codetickets/2217/

This requires a matching Simgear change, but ensure all places
tolerate Nasal subsystem being gone, since this occurs during reset.
This commit is contained in:
James Turner 2020-04-22 10:56:54 +01:00
parent 858fc6ea01
commit 381919451d
2 changed files with 9 additions and 6 deletions

View file

@ -86,7 +86,7 @@ public:
FGNasalSys* nasalSys = globals->get_subsystem<FGNasalSys>();
if (!nasalSys)
if (!nasalSys) // happens during shutdown / reset
return;
std::string moduleName = "scenario_" + _internalName;

View file

@ -96,14 +96,14 @@ public:
func(f),
object(obj)
{
FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
FGNasalSys* sys = globals->get_subsystem<FGNasalSys>();
_gcKeys[0] = sys->gcSave(f);
_gcKeys[1] = sys->gcSave(obj);
}
virtual void onFileDialogDone(FGFileDialog* instance, const SGPath& aPath)
void onFileDialogDone(FGFileDialog* instance, const SGPath& aPath) override
{
FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
FGNasalSys* sys = globals->get_subsystem<FGNasalSys>();
naContext ctx = naNewContext();
naRef args[1];
@ -115,7 +115,10 @@ public:
~NasalCallback()
{
FGNasalSys* sys = static_cast<FGNasalSys*>(globals->get_subsystem("nasal"));
FGNasalSys* sys = globals->get_subsystem<FGNasalSys>();
if (!sys) // happens during Nasal shutdown on reset
return;
sys->gcRelease(_gcKeys[0]);
sys->gcRelease(_gcKeys[1]);
}