shape: Free platform-specific shaped window data.

Fixes #2128.
main
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 */
if (window->shaper) {
CFBridgingRelease(window->shaper->driverdata);
SDL_free(window->shaper);
window->shaper = NULL;
}
}
window->driverdata = NULL;
}}

View File

@ -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()) */

View File

@ -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)
if (resized_properly != 0) {
SDL_free(result->driverdata);
SDL_free(result);
window->shaper = NULL;
return NULL;
}
return result;
}

View File

@ -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);
}

View File

@ -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;