فهرست منبع

video: Explicitly disallow setting the parent of a window to itself

Doing so causes a cycle in the window hierarchy tree graph, which leads to infinite recursion when destroying the windows.
Frank Praznik 10 ماه پیش
والد
کامیت
ca9b7c8ea3
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      src/video/SDL_video.c

+ 4 - 0
src/video/SDL_video.c

@@ -3672,6 +3672,10 @@ bool SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent)
         CHECK_WINDOW_NOT_POPUP(parent, false);
     }
 
+    if (window == parent) {
+        return SDL_SetError("Cannot set the parent of a window to itself.");
+    }
+
     if (!_this->SetWindowParent) {
         return SDL_Unsupported();
     }