1
0
Fork 0

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.
This commit is contained in:
andy 2008-11-03 23:50:33 +00:00
parent 0fbf965b39
commit 78d3763b41

View 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) {