@@ -297,20 +297,6 @@ static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this)
297297 return 0 ;
298298}
299299
300- static void SDLCALL SDL_CleanupWindowTextureData (void * userdata , void * value )
301- {
302- SDL_WindowTextureData * data = (SDL_WindowTextureData * )value ;
303-
304- if (data -> texture ) {
305- SDL_DestroyTexture (data -> texture );
306- }
307- if (data -> renderer ) {
308- SDL_DestroyRenderer (data -> renderer );
309- }
310- SDL_free (data -> pixels );
311- SDL_free (data );
312- }
313-
314300static bool SDL_CreateWindowTexture (SDL_VideoDevice * _this , SDL_Window * window , SDL_PixelFormat * format , void * * pixels , int * pitch )
315301{
316302 SDL_PropertiesID props = SDL_GetWindowProperties (window );
@@ -401,7 +387,7 @@ static bool SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window,
401387 SDL_DestroyRenderer (renderer );
402388 return false;
403389 }
404- if (!SDL_SetPointerPropertyWithCleanup (props , SDL_PROP_WINDOW_TEXTUREDATA_POINTER , data , SDL_CleanupWindowTextureData , NULL )) {
390+ if (!SDL_SetPointerProperty (props , SDL_PROP_WINDOW_TEXTUREDATA_POINTER , data )) {
405391 SDL_DestroyRenderer (renderer );
406392 return false;
407393 }
@@ -530,7 +516,21 @@ static bool SDL_UpdateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window,
530516
531517static void SDL_DestroyWindowTexture (SDL_VideoDevice * _this , SDL_Window * window )
532518{
533- SDL_ClearProperty (SDL_GetWindowProperties (window ), SDL_PROP_WINDOW_TEXTUREDATA_POINTER );
519+ SDL_PropertiesID props = SDL_GetWindowProperties (window );
520+ if (SDL_HasProperty (props , SDL_PROP_WINDOW_TEXTUREDATA_POINTER )) {
521+ SDL_WindowTextureData * data = SDL_GetPointerProperty (props , SDL_PROP_WINDOW_TEXTUREDATA_POINTER , NULL );
522+
523+ if (data -> texture ) {
524+ SDL_DestroyTexture (data -> texture );
525+ }
526+ if (data -> renderer ) {
527+ SDL_DestroyRenderer (data -> renderer );
528+ }
529+ SDL_free (data -> pixels );
530+ SDL_free (data );
531+
532+ SDL_ClearProperty (props , SDL_PROP_WINDOW_TEXTUREDATA_POINTER );
533+ }
534534}
535535
536536static SDL_VideoDevice * _this = NULL ;
@@ -4492,6 +4492,8 @@ void SDL_DestroyWindow(SDL_Window *window)
44924492 }
44934493
44944494 SDL_DestroyProperties (window -> text_input_props );
4495+
4496+ SDL_DestroyWindowTexture (_this , window );
44954497 SDL_DestroyProperties (window -> props );
44964498
44974499 /* Clear the modal status, but don't unset the parent just yet, as it
0 commit comments