]> git.mxchange.org Git - flightgear.git/commitdiff
setprop(): make sure return value is always set
authormfranz <mfranz>
Thu, 11 Oct 2007 07:58:56 +0000 (07:58 +0000)
committermfranz <mfranz>
Thu, 11 Oct 2007 07:58:56 +0000 (07:58 +0000)
src/Scripting/NasalSys.cxx

index 16f910ce09a4944ee62f9c243634b2fc5f8ad641..7811895b2bcad71c1b300bb7d1681f68a4afb74a 100644 (file)
@@ -222,19 +222,19 @@ static naRef f_setprop(naContext c, naRef me, int argc, naRef* args)
 
     SGPropertyNode* props = globals->get_props();
     naRef val = args[argc-1];
-    bool ret;
     try {
-        if(naIsString(val)) ret = props->setStringValue(buf, naStr_data(val));
+        bool r;
+        if(naIsString(val)) r = props->setStringValue(buf, naStr_data(val));
         else {
             naRef n = naNumValue(val);
             if(naIsNil(n))
                 naRuntimeError(c, "setprop() value is not string or number");
-            ret = props->setDoubleValue(buf, n.num);
+            r = props->setDoubleValue(buf, n.num);
         }
+        if(!r) naRuntimeError(c, "setprop(): property is not writable");
     } catch (const string& err) {
         naRuntimeError(c, (char *)err.c_str());
     }
-    if(!ret) naRuntimeError(c, "setprop(): property is not writable");
     return naNil();
 #undef BUFLEN
 }