]> git.mxchange.org Git - flightgear.git/commitdiff
Fix refcounting bug in f_removeChild(). Use a smart pointer to handle
authorandy <andy>
Mon, 3 Nov 2008 23:50:33 +0000 (23:50 +0000)
committerandy <andy>
Mon, 3 Nov 2008 23:50:33 +0000 (23:50 +0000)
the case where the removed child has no other referants, otherwise it
will be deleted on function exit.  Also give the ghost type a name for
cleaner debugging.

src/Scripting/nasal-props.cxx

index 939e19305c378d7a4ca46099dc595c0d688abe97..4e1777b2eb62858615726383cb8af4ccb5f734ef 100644 (file)
@@ -26,7 +26,7 @@ static void propNodeGhostDestroy(void* ghost)
     delete prop;
 }
 
-naGhostType PropNodeGhostType = { propNodeGhostDestroy };
+naGhostType PropNodeGhostType = { propNodeGhostDestroy, "prop" };
 
 static naRef propNodeGhostCreate(naContext c, SGPropertyNode* n)
 {
@@ -267,7 +267,7 @@ static naRef f_removeChild(naContext c, naRef me, int argc, naRef* args)
     naRef child = naVec_get(argv, 0);
     naRef index = naVec_get(argv, 1);
     if(!naIsString(child) || !naIsNum(index)) return naNil();
-    SGPropertyNode* n = 0;
+    SGPropertyNode_ptr n = 0;
     try {
         n = (*node)->removeChild(naStr_data(child), (int)index.num, false);
     } catch (const string& err) {