Clear ATCDialog instance on reset
Showed up as a variety of crashes on Sentry, due to a stale instance of this object hanging around after reset. Sentry-Id:FLIGHTGEAR-T5
This commit is contained in:
parent
6caadf2450
commit
64b03b70a8
3 changed files with 36 additions and 0 deletions
|
@ -214,6 +214,14 @@ void FGATCDialogNew::init() {
|
||||||
globals->get_props()->setIntValue("/sim/atc/transmission-num", -1);
|
globals->get_props()->setIntValue("/sim/atc/transmission-num", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGATCDialogNew::shutdown()
|
||||||
|
{
|
||||||
|
auto commands = globals->get_commands();
|
||||||
|
commands->removeCommand("ATC-dialog");
|
||||||
|
commands->removeCommand("ATC-freq-search");
|
||||||
|
commands->removeCommand("ATC-freq-display");
|
||||||
|
}
|
||||||
|
|
||||||
// Display the ATC popup dialog box with options relevant to the users current situation.
|
// Display the ATC popup dialog box with options relevant to the users current situation.
|
||||||
//
|
//
|
||||||
// So, the first thing we need to do is check the frequency that our pilot's nav radio
|
// So, the first thing we need to do is check the frequency that our pilot's nav radio
|
||||||
|
@ -242,6 +250,15 @@ void FGATCDialogNew::PopupDialog() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGATCDialogNew::hackyReset()
|
||||||
|
{
|
||||||
|
if (_instance) {
|
||||||
|
_instance->shutdown();
|
||||||
|
delete _instance;
|
||||||
|
_instance = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FGATCDialogNew::update(double dt) {
|
void FGATCDialogNew::update(double dt) {
|
||||||
// double onBoardRadioFreq0 =
|
// double onBoardRadioFreq0 =
|
||||||
// fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
|
// fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
class NewGUI;
|
class NewGUI;
|
||||||
class SGPropertyNode;
|
class SGPropertyNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* despite looking like a subsystem, this is not, at the moment.
|
||||||
|
* So don't assume it has subsystem semantics or behaviour.
|
||||||
|
* For 'next' we're fixing this, but it's too complex a change for 2020.3
|
||||||
|
*/
|
||||||
class FGATCDialogNew
|
class FGATCDialogNew
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -52,6 +57,7 @@ public:
|
||||||
void frequencyDisplay(const std::string& ident);
|
void frequencyDisplay(const std::string& ident);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
void shutdown();
|
||||||
|
|
||||||
void update(double dt);
|
void update(double dt);
|
||||||
void PopupDialog();
|
void PopupDialog();
|
||||||
|
@ -63,6 +69,14 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hacky fix for various crashes on reset: give a way to reset instance
|
||||||
|
* back to null-ptr, so that we get a new instance created.
|
||||||
|
* Without this, we crash in various exciting ways due to stale pointers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void hackyReset();
|
||||||
|
|
||||||
// Generate new instance of FGATCDialogNew if it hasn't yet been generated
|
// Generate new instance of FGATCDialogNew if it hasn't yet been generated
|
||||||
// Call constructor and init() functions
|
// Call constructor and init() functions
|
||||||
// If it has been generated, will return that instance
|
// If it has been generated, will return that instance
|
||||||
|
|
|
@ -1265,6 +1265,11 @@ void fgStartNewReset()
|
||||||
|
|
||||||
subsystemManger->shutdown();
|
subsystemManger->shutdown();
|
||||||
subsystemManger->unbind();
|
subsystemManger->unbind();
|
||||||
|
|
||||||
|
// hack fix for many reset crashes relating to the static instance
|
||||||
|
// of this class. Will be fixed better for future versions by making
|
||||||
|
// this a proper subsystem.
|
||||||
|
FGATCDialogNew::hackyReset();
|
||||||
|
|
||||||
// remove most subsystems, with a few exceptions.
|
// remove most subsystems, with a few exceptions.
|
||||||
for (int g=0; g<SGSubsystemMgr::MAX_GROUPS; ++g) {
|
for (int g=0; g<SGSubsystemMgr::MAX_GROUPS; ++g) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue