1
0
Fork 0

Error-reporter: don't crash on reset

Sentry-Id: FLIGHTGEAR-QFP
This commit is contained in:
James Turner 2021-07-26 11:48:06 +01:00
parent 39f761e171
commit 19a010307d
2 changed files with 17 additions and 5 deletions

View file

@ -768,8 +768,10 @@ void ErrorReporter::init()
SG_LOG(SG_GENERAL, SG_INFO, "Error reporting disabled");
simgear::setFailureCallback(simgear::FailureCallback());
simgear::setErrorContextCallback(simgear::ContextCallback());
sglog().removeCallback(d->_logCallback.get());
d->_logCallbackRegistered = false;
if (d->_logCallbackRegistered) {
sglog().removeCallback(d->_logCallback.get());
d->_logCallbackRegistered = false;
}
return;
}
@ -885,8 +887,14 @@ void ErrorReporter::shutdown()
globals->get_commands()->removeCommand("dismiss-error-report");
globals->get_commands()->removeCommand("save-error-report-data");
globals->get_commands()->removeCommand("show-error-report");
sglog().removeCallback(d->_logCallback.get());
d->_logCallbackRegistered = false;
// during a reset we don't want to touch the log callback; it was added in
// preinit, which does not get repeated on a reset
const bool inReset = fgGetBool("/sim/signals/reinit", false);
if (!inReset) {
sglog().removeCallback(d->_logCallback.get());
d->_logCallbackRegistered = false;
}
}
}

View file

@ -155,6 +155,7 @@
#include "util.hxx"
#include "AircraftDirVisitorBase.hxx"
#include <Main/sentryIntegration.hxx>
#include <Main/ErrorReporter.hxx>
#if defined(SG_MAC)
#include <GUI/CocoaHelpers.h> // for Mac impl of platformDefaultDataPath()
@ -1235,7 +1236,10 @@ void fgStartNewReset()
SGSubsystemGroup* grp = subsystemManger->get_group(static_cast<SGSubsystemMgr::GroupType>(g));
for (auto nm : grp->member_names()) {
if ((nm == "time") || (nm == "terrasync") || (nm == "events")
|| (nm == "lighting") || (nm == FGScenery::staticSubsystemClassId()))
|| (nm == "lighting")
|| (nm == FGScenery::staticSubsystemClassId())
|| (nm == flightgear::ErrorReporter::staticSubsystemClassId())
)
{
continue;
}