From 775e4cecff88095155500bb29f3a240acfe64dec Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 19:09:36 +0200 Subject: [PATCH] pgraph: fix freeze in garbage_collect(), esp. when rate-limit is on --- panda/src/pgraph/renderAttrib.cxx | 5 ++++- panda/src/pgraph/renderState.cxx | 3 +++ panda/src/pgraph/transformState.cxx | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 73b1e4b392..9bac4e666a 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -211,7 +211,7 @@ garbage_collect() { } num_this_pass = std::min(num_this_pass, size); - size_t stop_at_element = (_garbage_index + num_this_pass) % size; + size_t stop_at_element = (si + num_this_pass) % size; do { RenderAttrib *attrib = (RenderAttrib *)_attribs->get_key(si); @@ -229,6 +229,9 @@ garbage_collect() { // still need to visit. --size; --si; + if (stop_at_element > 0) { + --stop_at_element; + } } si = (si + 1) % size; diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 927d1e7073..5ce1527247 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -950,6 +950,9 @@ garbage_collect() { // still need to visit. --size; --si; + if (stop_at_element > 0) { + --stop_at_element; + } } si = (si + 1) % size; diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index 453fb505b4..4d02425683 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -1216,6 +1216,9 @@ garbage_collect() { // still need to visit. --size; --si; + if (stop_at_element > 0) { + --stop_at_element; + } } si = (si + 1) % size;