From f6fe58c262db747fbb78520f63e541b9b0035af6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 27 Oct 2003 20:54:14 +0000 Subject: [PATCH] keep reference count during statsh --- panda/src/pgraph/pandaNode.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 74036d5431..023cbf9995 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -1654,6 +1654,10 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed) { nassertr(child != (NodePathComponent *)NULL, false); + // Keep a reference count to the new parent, since detaching the + // child might lose the count. + PT(NodePathComponent) keep_parent = new_parent; + if (!child->is_top_node()) { detach(child); }