Browse Source

Fix crash with window creation in an event

rdb 16 years ago
parent
commit
d2df9f3618
1 changed files with 5 additions and 4 deletions
  1. 5 4
      panda/src/display/graphicsEngine.cxx

+ 5 - 4
panda/src/display/graphicsEngine.cxx

@@ -1517,10 +1517,11 @@ make_contexts(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
 ////////////////////////////////////////////////////////////////////
 void GraphicsEngine::
 process_events(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
-  Windows::const_iterator wi;
-  for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
-    GraphicsOutput *win = (*wi);
-    win->process_events();
+  // We're not using a vector iterator here, since it's possible that
+  // the window list changes in an event, which would invalidate the
+  // iterator and cause a crash.
+  for (int i = 0; i < wlist.size(); ++i) {
+    wlist[i]->process_events();
   }
 }