]> git.mxchange.org Git - flightgear.git/commitdiff
setprop(): report error on writing to unwritable property
authormfranz <mfranz>
Wed, 10 Oct 2007 19:24:17 +0000 (19:24 +0000)
committermfranz <mfranz>
Wed, 10 Oct 2007 19:24:17 +0000 (19:24 +0000)
src/Scripting/NasalSys.cxx

index c2d6d42951e93075016eb09d287e8106ff45dca5..92ec647dfe19779a4c8311e9ab1d40e800c2265e 100644 (file)
@@ -222,17 +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)) props->setStringValue(buf, naStr_data(val));
+        if(naIsString(val)) ret = props->setStringValue(buf, naStr_data(val));
         else {
             naRef n = naNumValue(val);
             if(naIsNil(n))
                 naRuntimeError(c, "setprop() value is not string or number");
-            props->setDoubleValue(buf, n.num);
+            ret = props->setDoubleValue(buf, n.num);
         }
     } catch (const string& err) {
         naRuntimeError(c, (char *)err.c_str());
     }
+    if(!ret) naRuntimeError(c, "setprop(): property is not writable");
     return naNil();
 #undef BUFLEN
 }