Преглед на файлове

windisplay: Fix recursive loop in adjust_z_order

Cherry-pick of 639497310e2972eae81ee825dbdff14cdc02c520 with alteration
to preserve ABI (replacing an unused bool field)
rdb преди 1 година
родител
ревизия
d020b25afe
променени са 2 файла, в които са добавени 11 реда и са изтрити 2 реда
  1. 10 1
      panda/src/windisplay/winGraphicsWindow.cxx
  2. 1 1
      panda/src/windisplay/winGraphicsWindow.h

+ 10 - 1
panda/src/windisplay/winGraphicsWindow.cxx

@@ -1308,6 +1308,11 @@ adjust_z_order() {
 void WinGraphicsWindow::
 adjust_z_order(WindowProperties::ZOrder last_z_order,
                WindowProperties::ZOrder this_z_order) {
+  // Prevent calling this recursively.
+  if (_in_adjust_z_order) {
+    return;
+  }
+
   HWND order;
   bool do_change = false;
 
@@ -1337,8 +1342,10 @@ adjust_z_order(WindowProperties::ZOrder last_z_order,
     break;
   }
   if (do_change) {
+    _in_adjust_z_order = true;
     BOOL result = SetWindowPos(_hWnd, order, 0,0,0,0,
                                SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE);
+    _in_adjust_z_order = false;
     if (!result) {
       windisplay_cat.warning()
         << "SetWindowPos failed.\n";
@@ -1630,7 +1637,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
     if (_hWnd != nullptr) {
       handle_reshape();
     }
-    adjust_z_order();
+    if (!_in_adjust_z_order) {
+      adjust_z_order();
+    }
     return 0;
 
   case WM_PAINT:

+ 1 - 1
panda/src/windisplay/winGraphicsWindow.h

@@ -173,7 +173,7 @@ private:
   bool _ime_open;
   bool _ime_active;
   bool _tracking_mouse_leaving;
-  bool _bCursor_in_WindowClientArea;
+  bool _in_adjust_z_order = false;
   HANDLE _input_device_handle[32];
   HCURSOR _cursor;
   DEVMODE _fullscreen_display_mode;