Fixed bug 2860 - SetProp must be paired with RemoveProp especially for properties added to external windows
authorSam Lantinga <slouken@libsdl.org>
Thu, 28 May 2015 08:41:07 -0700
changeset 966442ab66d97cc1
parent 9663 647180a6caad
child 9665 8d24b4bfa3dd
Fixed bug 2860 - SetProp must be paired with RemoveProp especially for properties added to external windows

Coriiander

Upon creating a window, a window property is added to it through the Win32-function "SetProp". This is done in the SDL-function "SetupWindowData" in file "src\video\windows\SDL_windowswindow.c".

Whenever you call "SetProp" to add a property to a Win32-window, you should also call the Win32-function "RemoveProp" to remove it before destroying that Win32-window.

While you might think that it's ok and that Windows will clean up nicely itself, it is not ok. It is against all Win32-API guidelines and is mostlikely a leak. Especially on external windows (CreateWindowFrom) you want to have things done right, not messy and leaky, affecting some other module. Even if SDL gets shutdown entirely that external window will now forever still have the "SDL_WindowData" prop attached to it.
src/video/windows/SDL_windowswindow.c
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Thu May 28 01:27:24 2015 -0400
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Thu May 28 08:41:07 2015 -0700
     1.3 @@ -615,6 +615,7 @@
     1.4  
     1.5      if (data) {
     1.6          ReleaseDC(data->hwnd, data->hdc);
     1.7 +        ReleaseProp(data->hwnd, TEXT("SDL_WindowData"));
     1.8          if (data->created) {
     1.9              DestroyWindow(data->hwnd);
    1.10          } else {