protect against recursive entry to do_pending()

This commit is contained in:
David Rose 2009-09-08 02:15:10 +00:00
parent 61bb918380
commit 154812d25a

View File

@ -2296,6 +2296,7 @@ add_window(Windows &wlist, GraphicsOutput *window) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GraphicsEngine::WindowRenderer:: void GraphicsEngine::WindowRenderer::
remove_window(GraphicsOutput *window) { remove_window(GraphicsOutput *window) {
nassertv(window != NULL);
LightReMutexHolder holder(_wl_lock); LightReMutexHolder holder(_wl_lock);
PT(GraphicsOutput) ptwin = window; PT(GraphicsOutput) ptwin = window;
@ -2481,13 +2482,16 @@ do_pending(GraphicsEngine *engine, Thread *current_thread) {
<< "_pending_close.size() = " << _pending_close.size() << "\n"; << "_pending_close.size() = " << _pending_close.size() << "\n";
} }
// Close any windows that were pending closure. // Close any windows that were pending closure. Carefully protect
// against recursive entry to this function by swapping the vector
// to a local copy first.
Windows::iterator wi; Windows::iterator wi;
for (wi = _pending_close.begin(); wi != _pending_close.end(); ++wi) { Windows pending_close;
_pending_close.swap(pending_close);
for (wi = pending_close.begin(); wi != pending_close.end(); ++wi) {
GraphicsOutput *win = (*wi); GraphicsOutput *win = (*wi);
win->set_close_now(); win->set_close_now();
} }
_pending_close.clear();
} }
} }