shape: Free platform-specific shaped window data. Fixes #2128.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index ec223c6..eea7f98 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -2370,6 +2370,12 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
}
#endif /* SDL_VIDEO_OPENGL */
+
+ if (window->shaper) {
+ CFBridgingRelease(window->shaper->driverdata);
+ SDL_free(window->shaper);
+ window->shaper = NULL;
+ }
}
window->driverdata = NULL;
}}
diff --git a/src/video/os2/SDL_os2video.c b/src/video/os2/SDL_os2video.c
index a9599c8..599384e 100644
--- a/src/video/os2/SDL_os2video.c
+++ b/src/video/os2/SDL_os2video.c
@@ -914,6 +914,17 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window)
if (pWinData == NULL)
return;
+ if (pWinData->hrgnShape != NULLHANDLE) {
+ HPS hps = WinGetPS(pWinData->hwnd);
+ GpiDestroyRegion(hps, pWinData->hrgnShape);
+ WinReleasePS(hps);
+ }
+
+ if (window->shaper) {
+ SDL_free(window->shaper);
+ window->shaper = NULL;
+ }
+
if (pWinData->fnUserWndProc == NULL) {
/* Window was created by SDL (OS2_CreateWindow()),
* not by user (OS2_CreateWindowFrom()) */
diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c
index ef716a5..919076f 100644
--- a/src/video/windows/SDL_windowsshape.c
+++ b/src/video/windows/SDL_windowsshape.c
@@ -36,11 +36,15 @@ Win32_CreateShaper(SDL_Window * window) {
result->hasshape = SDL_FALSE;
result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
- /* Put some driver-data here. */
window->shaper = result;
+ /* Put some driver-data here. */
resized_properly = Win32_ResizeWindowShape(window);
- if (resized_properly != 0)
- return NULL;
+ if (resized_properly != 0) {
+ SDL_free(result->driverdata);
+ SDL_free(result);
+ window->shaper = NULL;
+ return NULL;
+ }
return result;
}
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 77417b2..488b6fe 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -34,6 +34,7 @@
#include "SDL_windowsvideo.h"
#include "SDL_windowswindow.h"
+#include "SDL_windowsshape.h"
#include "SDL_hints.h"
#include "SDL_timer.h"
@@ -1168,6 +1169,18 @@ WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
void
WIN_DestroyWindow(_THIS, SDL_Window * window)
{
+ if (window->shaper) {
+ SDL_ShapeData *shapedata = (SDL_ShapeData *) window->shaper->driverdata;
+ if (shapedata) {
+ if (shapedata->mask_tree) {
+ SDL_FreeShapeTree(&shapedata->mask_tree);
+ }
+ SDL_free(shapedata);
+ }
+ SDL_free(window->shaper);
+ window->shaper = NULL;
+ }
+
CleanupWindowData(_this, window);
}
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index bfba775..770116b 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -1686,6 +1686,16 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+ if (window->shaper) {
+ SDL_ShapeData *shapedata = (SDL_ShapeData *) window->shaper->driverdata;
+ if (shapedata) {
+ SDL_free(shapedata->bitmap);
+ SDL_free(shapedata);
+ }
+ SDL_free(window->shaper);
+ window->shaper = NULL;
+ }
+
if (data) {
SDL_VideoData *videodata = (SDL_VideoData *) data->videodata;
Display *display = videodata->display;