From 78d3763b41641d7e959c5701cba7bfbbfd04e766 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 3 Nov 2008 23:50:33 +0000 Subject: [PATCH] Fix refcounting bug in f_removeChild(). Use a smart pointer to handle 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Scripting/nasal-props.cxx b/src/Scripting/nasal-props.cxx index 939e19305..4e1777b2e 100644 --- a/src/Scripting/nasal-props.cxx +++ b/src/Scripting/nasal-props.cxx @@ -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) { -- 2.39.5