shape: Free platform-specific shaped window data.

Fixes #2128.
This commit is contained in:
Ryan C. Gordon 2022-10-25 23:13:34 -04:00
parent 30c2dac787
commit c8d20f96ba
5 changed files with 47 additions and 3 deletions

View File

@ -2370,6 +2370,12 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
} }
#endif /* SDL_VIDEO_OPENGL */ #endif /* SDL_VIDEO_OPENGL */
if (window->shaper) {
CFBridgingRelease(window->shaper->driverdata);
SDL_free(window->shaper);
window->shaper = NULL;
}
} }
window->driverdata = NULL; window->driverdata = NULL;
}} }}

View File

@ -914,6 +914,17 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window)
if (pWinData == NULL) if (pWinData == NULL)
return; 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) { if (pWinData->fnUserWndProc == NULL) {
/* Window was created by SDL (OS2_CreateWindow()), /* Window was created by SDL (OS2_CreateWindow()),
* not by user (OS2_CreateWindowFrom()) */ * not by user (OS2_CreateWindowFrom()) */

View File

@ -36,11 +36,15 @@ Win32_CreateShaper(SDL_Window * window) {
result->hasshape = SDL_FALSE; result->hasshape = SDL_FALSE;
result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData)); result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
((SDL_ShapeData*)result->driverdata)->mask_tree = NULL; ((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
/* Put some driver-data here. */
window->shaper = result; window->shaper = result;
/* Put some driver-data here. */
resized_properly = Win32_ResizeWindowShape(window); resized_properly = Win32_ResizeWindowShape(window);
if (resized_properly != 0) if (resized_properly != 0) {
return NULL; SDL_free(result->driverdata);
SDL_free(result);
window->shaper = NULL;
return NULL;
}
return result; return result;
} }

View File

@ -34,6 +34,7 @@
#include "SDL_windowsvideo.h" #include "SDL_windowsvideo.h"
#include "SDL_windowswindow.h" #include "SDL_windowswindow.h"
#include "SDL_windowsshape.h"
#include "SDL_hints.h" #include "SDL_hints.h"
#include "SDL_timer.h" #include "SDL_timer.h"
@ -1168,6 +1169,18 @@ WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
void void
WIN_DestroyWindow(_THIS, SDL_Window * window) 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); CleanupWindowData(_this, window);
} }

View File

@ -1686,6 +1686,16 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 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) { if (data) {
SDL_VideoData *videodata = (SDL_VideoData *) data->videodata; SDL_VideoData *videodata = (SDL_VideoData *) data->videodata;
Display *display = videodata->display; Display *display = videodata->display;