ErrorReporter: fix a crash on exit found by ASan
If we exit without shutdown()-ing the error report, ensure the error logging callback is cleaned up.
This commit is contained in:
parent
81e12d7c2e
commit
6a7de07fda
2 changed files with 14 additions and 0 deletions
|
@ -213,6 +213,7 @@ public:
|
||||||
using OccurrenceVec = std::vector<ErrorOcurrence>;
|
using OccurrenceVec = std::vector<ErrorOcurrence>;
|
||||||
|
|
||||||
std::unique_ptr<RecentLogCallback> _logCallback;
|
std::unique_ptr<RecentLogCallback> _logCallback;
|
||||||
|
bool _logCallbackRegistered = false;
|
||||||
|
|
||||||
string _terrasyncPathPrefix;
|
string _terrasyncPathPrefix;
|
||||||
string _fgdataPathPrefix;
|
string _fgdataPathPrefix;
|
||||||
|
@ -709,6 +710,15 @@ ErrorReporter::ErrorReporter() : d(new ErrorReporterPrivate)
|
||||||
"/scenery/use-vpb"};
|
"/scenery/use-vpb"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorReporter::~ErrorReporter()
|
||||||
|
{
|
||||||
|
// if we are deleted withut being shutdown(), ensure we clean
|
||||||
|
// up our logging callback
|
||||||
|
if (d->_logCallbackRegistered) {
|
||||||
|
sglog().removeCallback(d->_logCallback.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ErrorReporter::bind()
|
void ErrorReporter::bind()
|
||||||
{
|
{
|
||||||
SGPropertyNode_ptr n = fgGetNode("/sim/error-report", true);
|
SGPropertyNode_ptr n = fgGetNode("/sim/error-report", true);
|
||||||
|
@ -742,6 +752,7 @@ void ErrorReporter::preinit()
|
||||||
});
|
});
|
||||||
|
|
||||||
sglog().addCallback(d->_logCallback.get());
|
sglog().addCallback(d->_logCallback.get());
|
||||||
|
d->_logCallbackRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorReporter::init()
|
void ErrorReporter::init()
|
||||||
|
@ -758,6 +769,7 @@ void ErrorReporter::init()
|
||||||
simgear::setFailureCallback(simgear::FailureCallback());
|
simgear::setFailureCallback(simgear::FailureCallback());
|
||||||
simgear::setErrorContextCallback(simgear::ContextCallback());
|
simgear::setErrorContextCallback(simgear::ContextCallback());
|
||||||
sglog().removeCallback(d->_logCallback.get());
|
sglog().removeCallback(d->_logCallback.get());
|
||||||
|
d->_logCallbackRegistered = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,6 +886,7 @@ void ErrorReporter::shutdown()
|
||||||
globals->get_commands()->removeCommand("save-error-report-data");
|
globals->get_commands()->removeCommand("save-error-report-data");
|
||||||
globals->get_commands()->removeCommand("show-error-report");
|
globals->get_commands()->removeCommand("show-error-report");
|
||||||
sglog().removeCallback(d->_logCallback.get());
|
sglog().removeCallback(d->_logCallback.get());
|
||||||
|
d->_logCallbackRegistered = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ErrorReporter : public SGSubsystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ErrorReporter();
|
ErrorReporter();
|
||||||
|
~ErrorReporter();
|
||||||
|
|
||||||
void preinit();
|
void preinit();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue