From ee6d7813a638f7567aa41fb6cb2d1099f2b6be26 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Mon, 12 Feb 2007 19:39:28 +0000 Subject: [PATCH] Fixed a bad iterator --- panda/src/pgraph/pandaNode.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 6aa1266286..04a64896ff 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -2730,17 +2730,21 @@ detach_one_stage(NodePathComponent *child, int pipeline_stage, Down::iterator di; bool found = false; Down &down = *cdata_parent->modify_down(); - for (di = down.begin(); di != down.end() && !found; ++di) { + for (di = down.begin(); di != down.end(); ++di) { if ((*di).get_child() == child_node) { down.erase(di); found = true; + break; } } - Down &stashed = *cdata_parent->modify_stashed(); - for (di = stashed.begin(); di != stashed.end() && !found; ++di) { - if ((*di).get_child() == child_node) { - stashed.erase(di); - found = true; + if (!found) { + Down &stashed = *cdata_parent->modify_stashed(); + for (di = stashed.begin(); di != stashed.end(); ++di) { + if ((*di).get_child() == child_node) { + stashed.erase(di); + found = true; + break; + } } } nassertv(found);