Clean up parent window when destroying a window
authorSam Lantinga <slouken@libsdl.org>
Fri, 16 Jun 2017 10:50:29 -0700
changeset 111010d7498130972
parent 11100 e99cf4079ace
child 11102 2612ccd5b558
Clean up parent window when destroying a window
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Fri Jun 16 09:10:13 2017 -0700
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Fri Jun 16 10:50:29 2017 -0700
     1.3 @@ -114,7 +114,7 @@
     1.4  }
     1.5  
     1.6  static int
     1.7 -SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
     1.8 +SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool created)
     1.9  {
    1.10      SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
    1.11      SDL_WindowData *data;
    1.12 @@ -126,6 +126,7 @@
    1.13      }
    1.14      data->window = window;
    1.15      data->hwnd = hwnd;
    1.16 +    data->parent = parent;
    1.17      data->hdc = GetDC(hwnd);
    1.18      data->hinstance = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
    1.19      data->created = created;
    1.20 @@ -300,8 +301,11 @@
    1.21  
    1.22      WIN_PumpEvents(_this);
    1.23  
    1.24 -    if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) {
    1.25 +    if (SetupWindowData(_this, window, hwnd, parent, SDL_TRUE) < 0) {
    1.26          DestroyWindow(hwnd);
    1.27 +        if (parent) {
    1.28 +            DestroyWindow(parent);
    1.29 +        }
    1.30          return -1;
    1.31      }
    1.32  
    1.33 @@ -362,7 +366,7 @@
    1.34          SDL_stack_free(title);
    1.35      }
    1.36  
    1.37 -    if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
    1.38 +    if (SetupWindowData(_this, window, hwnd, NULL, SDL_FALSE) < 0) {
    1.39          return -1;
    1.40      }
    1.41  
    1.42 @@ -680,6 +684,9 @@
    1.43          RemoveProp(data->hwnd, TEXT("SDL_WindowData"));
    1.44          if (data->created) {
    1.45              DestroyWindow(data->hwnd);
    1.46 +            if (data->parent) {
    1.47 +                DestroyWindow(data->parent);
    1.48 +            }
    1.49          } else {
    1.50              /* Restore any original event handler... */
    1.51              if (data->wndproc != NULL) {
     2.1 --- a/src/video/windows/SDL_windowswindow.h	Fri Jun 16 09:10:13 2017 -0700
     2.2 +++ b/src/video/windows/SDL_windowswindow.h	Fri Jun 16 10:50:29 2017 -0700
     2.3 @@ -31,6 +31,7 @@
     2.4  {
     2.5      SDL_Window *window;
     2.6      HWND hwnd;
     2.7 +    HWND parent;
     2.8      HDC hdc;
     2.9      HDC mdc;
    2.10      HINSTANCE hinstance;