Catch exceptions in FDM init more precisely
Rather than letting these rise to the global handler, do a more targeted message.
This commit is contained in:
parent
f6a11ced91
commit
073784fa03
2 changed files with 26 additions and 15 deletions
src/FDM
|
@ -170,6 +170,29 @@ void FDMShell::unbind()
|
||||||
_tankProperties.unbind();
|
_tankProperties.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FDMShell::doInitAndBind()
|
||||||
|
{
|
||||||
|
SG_LOG(SG_FLIGHT, SG_INFO, "Scenery loaded, will init FDM");
|
||||||
|
try {
|
||||||
|
_impl->init();
|
||||||
|
if (_impl->get_bound()) {
|
||||||
|
_impl->unbind();
|
||||||
|
}
|
||||||
|
_impl->bind();
|
||||||
|
|
||||||
|
fgSetBool("/sim/fdm-initialized", true);
|
||||||
|
fgSetBool("/sim/signals/fdm-initialized", true);
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
flightgear::fatalMessageBoxThenExit("Aircraft FDM initialization error",
|
||||||
|
string{"The aircraft flight dynamics model contains errors and cannot be used. ("} + e.what() + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!copyProperties(_props->getNode("fdm", true),
|
||||||
|
_initialFdmProperties)) {
|
||||||
|
SG_LOG(SG_FLIGHT, SG_ALERT, "Failed to save initial FDM property state");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FDMShell::update(double dt)
|
void FDMShell::update(double dt)
|
||||||
{
|
{
|
||||||
if (!_impl) {
|
if (!_impl) {
|
||||||
|
@ -189,21 +212,7 @@ void FDMShell::update(double dt)
|
||||||
SGGeod geod = SGGeod::fromDeg(lon, lat);
|
SGGeod geod = SGGeod::fromDeg(lon, lat);
|
||||||
const auto startUpPositionFialized = fgGetBool("/sim/position-finalized", false);
|
const auto startUpPositionFialized = fgGetBool("/sim/position-finalized", false);
|
||||||
if (startUpPositionFialized && globals->get_scenery()->scenery_available(geod, range)) {
|
if (startUpPositionFialized && globals->get_scenery()->scenery_available(geod, range)) {
|
||||||
SG_LOG(SG_FLIGHT, SG_INFO, "Scenery loaded, will init FDM");
|
doInitAndBind();
|
||||||
_impl->init();
|
|
||||||
if (_impl->get_bound()) {
|
|
||||||
_impl->unbind();
|
|
||||||
}
|
|
||||||
_impl->bind();
|
|
||||||
|
|
||||||
fgSetBool("/sim/fdm-initialized", true);
|
|
||||||
fgSetBool("/sim/signals/fdm-initialized", true);
|
|
||||||
|
|
||||||
if (!copyProperties(_props->getNode("fdm", true),
|
|
||||||
_initialFdmProperties))
|
|
||||||
{
|
|
||||||
SG_LOG(SG_FLIGHT, SG_ALERT, "Failed to save initial FDM property state");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ private:
|
||||||
|
|
||||||
void validateOutputProperties();
|
void validateOutputProperties();
|
||||||
|
|
||||||
|
void doInitAndBind();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TankPropertiesList _tankProperties;
|
TankPropertiesList _tankProperties;
|
||||||
SGSharedPtr<FGInterface> _impl;
|
SGSharedPtr<FGInterface> _impl;
|
||||||
|
|
Loading…
Add table
Reference in a new issue