From ccd6a094f1f522510d6a342a0898b15dd41a6293 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 10 Jul 2011 21:25:16 +0200 Subject: [PATCH] Avoid creation of stray "/null" property nodes. "property-assign" command had a side-effect of creating stray "/null" nodes when assigning a value (since "getprop2" always creates some node). --- src/Main/fg_commands.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 7711f6b4f..ef2824089 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -726,15 +726,18 @@ static bool do_property_assign (const SGPropertyNode * arg) { SGPropertyNode * prop = get_prop(arg); - const SGPropertyNode * prop2 = get_prop2(arg); const SGPropertyNode * value = arg->getNode("value"); if (value != 0) return prop->setUnspecifiedValue(value->getStringValue()); - else if (prop2) - return prop->setUnspecifiedValue(prop2->getStringValue()); else - return false; + { + const SGPropertyNode * prop2 = get_prop2(arg); + if (prop2) + return prop->setUnspecifiedValue(prop2->getStringValue()); + else + return false; + } } @@ -1064,14 +1067,9 @@ static bool do_add_model (const SGPropertyNode * arg) { SGPropertyNode * model = fgGetNode("models", true); - for (int i = 0;; i++) { - if (i < 0) - return false; - if (!model->getChild("model", i, false)) { - model = model->getChild("model", i, true); - break; - } - } + int i; + for (i = 0; model->hasChild("model",i); i++); + model = model->getChild("model", i, true); copyProperties(arg, model); if (model->hasValue("elevation-m")) model->setDoubleValue("elevation-ft", model->getDoubleValue("elevation-m")