Browse Source

display: fix assert when app exits before window fully opens

Possibly addressing #403
rdb 7 years ago
parent
commit
b0c9000000
1 changed files with 9 additions and 2 deletions
  1. 9 2
      panda/src/display/graphicsEngine.cxx

+ 9 - 2
panda/src/display/graphicsEngine.cxx

@@ -593,8 +593,7 @@ remove_all_windows() {
   Windows old_windows;
   old_windows.swap(_windows);
   Windows::iterator wi;
-  for (wi = old_windows.begin(); wi != old_windows.end(); ++wi) {
-    GraphicsOutput *win = (*wi);
+  for (GraphicsOutput *win : old_windows) {
     nassertv(win != nullptr);
     do_remove_window(win, current_thread);
     GraphicsStateGuardian *gsg = win->get_gsg();
@@ -605,6 +604,14 @@ remove_all_windows() {
 
   {
     MutexHolder new_windows_holder(_new_windows_lock, current_thread);
+    for (GraphicsOutput *win : _new_windows) {
+      nassertv(win != nullptr);
+      do_remove_window(win, current_thread);
+      GraphicsStateGuardian *gsg = win->get_gsg();
+      if (gsg != nullptr) {
+        gsg->release_all();
+      }
+    }
     _new_windows.clear();
   }