fix LightAttrib crash

This commit is contained in:
David Rose 2007-07-17 17:20:40 +00:00
parent de7aed1306
commit ed91ab6162
1 changed files with 18 additions and 4 deletions

View File

@ -949,8 +949,17 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
while (ci != _off_lights.end()) {
PandaNode *node;
DCAST_INTO_R(node, p_list[pi++], pi);
NodePath np(node);
(*ci) = areg->lookup_node(np);
// We go through some effort to look up the node in the registry
// without creating a NodePath around it first (which would up,
// and then down, the reference count, possibly deleting the
// node).
int ni = areg->find_node(node->get_type(), node->get_name());
if (ni != -1) {
(*ci) = areg->get_node(ni);
} else {
(*ci) = NodePath(node);
}
++ci;
}
_off_lights.sort();
@ -959,8 +968,13 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
while (ci != _on_lights.end()) {
PandaNode *node;
DCAST_INTO_R(node, p_list[pi++], pi);
NodePath np(node);
(*ci) = areg->lookup_node(np);
int ni = areg->find_node(node->get_type(), node->get_name());
if (ni != -1) {
(*ci) = areg->get_node(ni);
} else {
(*ci) = NodePath(node);
}
++ci;
}
_on_lights.sort();