diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index cbc102e3c..e94e92623 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -805,7 +805,7 @@ void FGAIBase::bind() { // The property above was incorrectly labelled 'longitude-mode' up until // FG 2018.4, so create an alias in case anyone is relying on the old name auto node = props->getNode("controls/flight/longitude-mode", true); - node->alias(props->getNode("controls/flight/vertical-mode")); + node->alias(props->getNode("controls/flight/vertical-mode"), false); props->setDoubleValue("controls/flight/target-alt", altitude_ft); props->setDoubleValue("controls/flight/target-pitch", pitch); diff --git a/src/Aircraft/replay-internal.cxx b/src/Aircraft/replay-internal.cxx index 84cafaddf..6baeaf4a6 100644 --- a/src/Aircraft/replay-internal.cxx +++ b/src/Aircraft/replay-internal.cxx @@ -248,7 +248,7 @@ void FGReplayInternal::init() m_log_frame_times = fgGetNode("/sim/replay/log-frame-times", true); // alias to keep backward compatibility - fgGetNode("/sim/freeze/replay-state", true)->alias(m_replay_master); + fgGetNode("/sim/freeze/replay-state", true)->alias(m_replay_master, false); reinit(); } diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index d9ac121c5..db17a777c 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -198,8 +198,8 @@ FGJSBsim::FGJSBsim( double dt ) // deprecate sim-time-sec for simulation/sim-time-sec // remove alias with increased configuration file version number (2.1 or later) SGPropertyNode * node = fgGetNode("/fdm/jsbsim/simulation/sim-time-sec"); - fgGetNode("/fdm/jsbsim/sim-time-sec", true)->alias( node ); -// end of sim-time-sec deprecation patch + fgGetNode("/fdm/jsbsim/sim-time-sec", true)->alias(node, false); + // end of sim-time-sec deprecation patch _ai_wake_enabled = fgGetNode("fdm/ai-wake/enabled", true); diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 996cb99d5..7d071d4d1 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -115,7 +115,7 @@ void FGFDM::init() _gross_weight_lbs = _yasimN->getNode("gross-weight-lbs", true); // alias to older name - fgGetNode("/yasim/gross-weight-lbs", true)->alias(_gross_weight_lbs); + fgGetNode("/yasim/gross-weight-lbs", true)->alias(_gross_weight_lbs, false); // write some compile time information to property tree _yasimN->getNode("config-version",true)->setIntValue(_airplane.getVersion()); diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 1c027d95e..86f0b3abc 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -155,7 +155,7 @@ GPS::init () // waypoints // for compatibility, alias selected course down to wp/wp[1]/desired-course-deg SGPropertyNode* wp1Crs = _currentWayptNode->getChild("desired-course-deg", 0, true); - wp1Crs->alias(_gpsNode->getChild("desired-course-deg", 0, true)); + wp1Crs->alias(_gpsNode->getChild("desired-course-deg", 0, true), true); _tracking_bug_node = _gpsNode->getChild("tracking-bug", 0, true); @@ -167,12 +167,12 @@ GPS::init () // navradio slaving properties SGPropertyNode* toFlag = _gpsNode->getChild("to-flag", 0, true); - toFlag->alias(_currentWayptNode->getChild("to-flag")); - + toFlag->alias(_currentWayptNode->getChild("to-flag"), true); + SGPropertyNode* fromFlag = _gpsNode->getChild("from-flag", 0, true); - fromFlag->alias(_currentWayptNode->getChild("from-flag")); - -// autopilot drive properties + fromFlag->alias(_currentWayptNode->getChild("from-flag"), true); + + // autopilot drive properties _apDrivingFlag = fgGetNode("/autopilot/settings/gps-driving-true-heading", true); _apTrueHeading = fgGetNode("/autopilot/settings/true-heading-deg",true); diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index 42b92cef4..a99c90966 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -266,7 +266,7 @@ FGNavRadio::init () // dme-in-range is deprecated, // temporarily create dme-in-range alias for instrumentation/dme[0]/in-range // remove after flightgear 2.6.0 - node->getNode( "dme-in-range", true )->alias( fgGetNode("/instrumentation/dme[0]/in-range", true ) ); + node->getNode("dme-in-range", true)->alias(fgGetNode("/instrumentation/dme[0]/in-range", true), false); } void diff --git a/src/Instrumentation/transponder.cxx b/src/Instrumentation/transponder.cxx index 599a032de..1924a1803 100644 --- a/src/Instrumentation/transponder.cxx +++ b/src/Instrumentation/transponder.cxx @@ -147,9 +147,9 @@ void Transponder::init() if (_kt70Compat) { // alias the properties through SGPropertyNode_ptr output = node->getChild("outputs", 0, true); - output->getChild("flight-level", 0, true)->alias(_altitude_node); - output->getChild("id-code", 0, true)->alias(_idCode_node); - in_node->getChild("func-knob", 0, true)->alias(_knob_node); + output->getChild("flight-level", 0, true)->alias(_altitude_node, true); + output->getChild("id-code", 0, true)->alias(_idCode_node, true); + in_node->getChild("func-knob", 0, true)->alias(_knob_node, true); } } diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 8bef6c916..f6c623aa2 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -1864,7 +1864,7 @@ naRef FGNasalSys::setListener(naContext c, int argc, naRef* args) return naNil(); } - if (node->isTied()) { + if (node->isTied() || node->isAlias()) { const auto isSafe = node->getAttribute(SGPropertyNode::LISTENER_SAFE); if (!isSafe) { SG_LOG(SG_NASAL, SG_DEV_ALERT, "ERROR: Cannot add listener to tied property " << diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index bcfced050..c880934c5 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -801,12 +801,18 @@ static naRef f_alias(naContext c, naRef me, int argc, naRef* args) try { if(naIsString(prop)) al = globals->get_props()->getNode(naStr_data(prop), true); else if(naIsGhost(prop)) al = static_cast(naGhost_ptr(prop)); - else throw string("props.alias() with bad argument"); - } catch (const string& err) { - naRuntimeError(c, (char *)err.c_str()); + else + throw sg_exception("props.alias() with bad argument"); + } catch (sg_exception& err) { + naRuntimeError(c, err.what()); return naNil(); } - return naNum(node->alias(al)); + + bool withListeners = false; + if (naVec_size(argv) > 1) { + withListeners = static_cast(naVec_get(argv, 1).num) != 0; + } + return naNum(node->alias(al, withListeners)); }