Simplified SDL_SetProperty() and added SDL_SetPropertyWithCleanup()

Most of the time people won't need to set a cleanup callback, so we can simplify the more commonly used API.
This commit is contained in:
Sam Lantinga
2023-11-07 12:33:43 -08:00
parent a1941fad6c
commit aea6e6de6f
16 changed files with 61 additions and 34 deletions

View File

@@ -280,7 +280,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
SDL_DestroyRenderer(renderer);
return SDL_OutOfMemory();
}
SDL_SetProperty(props, SDL_WINDOWTEXTUREDATA, data, SDL_CleanupWindowTextureData, NULL);
SDL_SetPropertyWithCleanup(props, SDL_WINDOWTEXTUREDATA, data, SDL_CleanupWindowTextureData, NULL);
data->renderer = renderer;
} else {

View File

@@ -48,7 +48,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window
}
/* Save the info and return! */
SDL_SetProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE, surface, CleanupSurface, NULL);
SDL_SetPropertyWithCleanup(SDL_GetWindowProperties(window), DUMMY_SURFACE, surface, CleanupSurface, NULL);
*format = surface_format;
*pixels = surface->pixels;
*pitch = surface->pitch;

View File

@@ -57,7 +57,7 @@ int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
return SDL_OutOfMemory();
}
SDL_SetProperty(SDL_GetWindowProperties(window), N3DS_SURFACE, framebuffer, CleanupSurface, NULL);
SDL_SetPropertyWithCleanup(SDL_GetWindowProperties(window), N3DS_SURFACE, framebuffer, CleanupSurface, NULL);
*format = FRAMEBUFFER_FORMAT;
*pixels = framebuffer->pixels;
*pitch = framebuffer->pitch;

View File

@@ -48,7 +48,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi
}
/* Save the info and return! */
SDL_SetProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE, surface, CleanupSurface, NULL);
SDL_SetPropertyWithCleanup(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE, surface, CleanupSurface, NULL);
*format = surface_format;
*pixels = surface->pixels;
*pitch = surface->pitch;