From aea6e6de6f205bdcbb003d6de4030be72a8e5a6c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 7 Nov 2023 12:33:43 -0800 Subject: [PATCH] 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. --- include/SDL3/SDL_properties.h | 23 +++++++++++++++++-- src/SDL_properties.c | 9 ++++++-- src/dynapi/SDL_dynapi.sym | 1 + src/dynapi/SDL_dynapi_overrides.h | 1 + src/dynapi/SDL_dynapi_procs.h | 3 ++- src/render/SDL_render.c | 2 +- src/render/direct3d/SDL_render_d3d.c | 2 +- src/render/direct3d11/SDL_render_d3d11.c | 2 +- src/render/direct3d12/SDL_render_d3d12.c | 2 +- src/video/SDL_video.c | 2 +- src/video/dummy/SDL_nullframebuffer.c | 2 +- src/video/n3ds/SDL_n3dsframebuffer.c | 2 +- .../offscreen/SDL_offscreenframebuffer.c | 2 +- test/testautomation_properties.c | 18 +++++++-------- test/testautomation_video.c | 22 +++++++++--------- test/testffmpeg.c | 2 +- 16 files changed, 61 insertions(+), 34 deletions(-) diff --git a/include/SDL3/SDL_properties.h b/include/SDL3/SDL_properties.h index 66d12f614..9a6ebf315 100644 --- a/include/SDL3/SDL_properties.h +++ b/include/SDL3/SDL_properties.h @@ -95,7 +95,23 @@ extern DECLSPEC void SDLCALL SDL_UnlockProperties(SDL_PropertiesID props); /** * Set a property on a set of properties * - * By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications. + * \param props the properties to modify + * \param name the name of the property to modify + * \param value the new value of the property, or NULL to delete the property + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.0.0. + * + * \sa SDL_GetProperty + * \sa SDL_SetPropertyWithCleanup + */ +extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value); + +/** + * Set a property on a set of properties with a cleanup function that is called when the property is deleted * * \param props the properties to modify * \param name the name of the property to modify @@ -111,12 +127,15 @@ extern DECLSPEC void SDLCALL SDL_UnlockProperties(SDL_PropertiesID props); * \since This function is available since SDL 3.0.0. * * \sa SDL_GetProperty + * \sa SDL_SetProperty */ -extern DECLSPEC int SDLCALL SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata); +extern DECLSPEC int SDLCALL SDL_SetPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata); /** * Get a property on a set of properties * + * By convention, the names of properties that SDL exposes on objects will start with "SDL.", and properties that SDL uses internally will start with "SDL.internal.". These should be considered read-only and should not be modified by applications. + * * \param props the properties to query * \param name the name of the property to query * \returns the value of the property, or NULL if it is not set. diff --git a/src/SDL_properties.c b/src/SDL_properties.c index 0b8d79534..d0b9c60f1 100644 --- a/src/SDL_properties.c +++ b/src/SDL_properties.c @@ -183,7 +183,12 @@ void SDL_UnlockProperties(SDL_PropertiesID props) SDL_UnlockMutex(properties->lock); } -int SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata) +int SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value) +{ + return SDL_SetPropertyWithCleanup(props, name, value, NULL, NULL); +} + +int SDL_SetPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *value, void (SDLCALL *cleanup)(void *userdata, void *value), void *userdata) { SDL_Properties *properties = NULL; SDL_Property *property = NULL; @@ -274,7 +279,7 @@ void *SDL_GetProperty(SDL_PropertiesID props, const char *name) int SDL_ClearProperty(SDL_PropertiesID props, const char *name) { - return SDL_SetProperty(props, name, NULL, NULL, NULL); + return SDL_SetProperty(props, name, NULL); } void SDL_DestroyProperties(SDL_PropertiesID props) diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index ea6f8d71f..dc1899f9b 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -921,6 +921,7 @@ SDL3_0.0.0 { SDL_RWvprintf; SDL_AllocateEventMemory; SDL_GetDisplayProperties; + SDL_SetPropertyWithCleanup; # extra symbols go here (don't modify this line) local: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index c158f325e..35fff15ba 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -946,3 +946,4 @@ #define SDL_RWvprintf SDL_RWvprintf_REAL #define SDL_AllocateEventMemory SDL_AllocateEventMemory_REAL #define SDL_GetDisplayProperties SDL_GetDisplayProperties_REAL +#define SDL_SetPropertyWithCleanup SDL_SetPropertyWithCleanup_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 512056b56..9f28f6744 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -962,7 +962,7 @@ SDL_DYNAPI_PROC(IDXGIResource*,SDL_GetTextureDXGIResource,(SDL_Texture *a),(a),r SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_CreateProperties,(void),(),return) SDL_DYNAPI_PROC(int,SDL_LockProperties,(SDL_PropertiesID a),(a),return) SDL_DYNAPI_PROC(void,SDL_UnlockProperties,(SDL_PropertiesID a),(a),) -SDL_DYNAPI_PROC(int,SDL_SetProperty,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return) +SDL_DYNAPI_PROC(int,SDL_SetProperty,(SDL_PropertiesID a, const char *b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(void*,SDL_GetProperty,(SDL_PropertiesID a, const char *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_DestroyProperties,(SDL_PropertiesID a),(a),) SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetAudioStreamProperties,(SDL_AudioStream *a),(a),return) @@ -979,3 +979,4 @@ SDL_DYNAPI_PROC(int,SDL_EnterAppMainCallbacks,(int a, char *b[], SDL_AppInit_fun SDL_DYNAPI_PROC(size_t,SDL_RWvprintf,(SDL_RWops *a, const char *b, va_list c),(a,b,c),return) SDL_DYNAPI_PROC(void*,SDL_AllocateEventMemory,(size_t a),(a),return) SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetDisplayProperties,(SDL_DisplayID a),(a),return) +SDL_DYNAPI_PROC(int,SDL_SetPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index dbed72f0c..1d55c87b7 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -929,7 +929,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl renderer->hidden = SDL_FALSE; } - SDL_SetProperty(SDL_GetWindowProperties(window), SDL_WINDOWRENDERDATA, renderer, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), SDL_WINDOWRENDERDATA, renderer); SDL_SetRenderViewport(renderer, NULL); diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index cf2046e6c..abfe5d5e0 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1714,7 +1714,7 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) data->drawstate.cliprect_enabled_dirty = SDL_TRUE; data->drawstate.blend = SDL_BLENDMODE_INVALID; - SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d9.device", data->device, NULL, NULL); + SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d9.device", data->device); return renderer; } diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 3e9716c2c..f15344ad2 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -668,7 +668,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0); ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants); - SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d11.device", data->d3dDevice, NULL, NULL); + SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d11.device", data->d3dDevice); done: SAFE_RELEASE(d3dDevice); diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index ba4e1ebc1..7c0fa525a 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -1070,7 +1070,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } data->srvPoolHead = &data->srvPoolNodes[0]; - SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d12.device", data->d3dDevice, NULL, NULL); + SDL_SetProperty(SDL_GetRendererProperties(renderer), "SDL.renderer.d3d12.device", data->d3dDevice); done: SAFE_RELEASE(d3dDevice); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 280260785..a4f771b74 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -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 { diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index b2ef60445..5978d3b0a 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -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; diff --git a/src/video/n3ds/SDL_n3dsframebuffer.c b/src/video/n3ds/SDL_n3dsframebuffer.c index b2e0d93fe..46fe98ea0 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/src/video/n3ds/SDL_n3dsframebuffer.c @@ -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; diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index cd5feba64..7dea25a90 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -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; diff --git a/test/testautomation_properties.c b/test/testautomation_properties.c index ff49e8024..75ddc35b9 100644 --- a/test/testautomation_properties.c +++ b/test/testautomation_properties.c @@ -26,7 +26,7 @@ static int properties_testBasic(void *arg) for (i = 0; i < 10; ++i) { SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i); SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i); - result = SDL_SetProperty(props, key, expected_value, NULL, NULL); + result = SDL_SetProperty(props, key, expected_value); SDLTest_AssertPass("Call to SDL_SetProperty()"); SDLTest_AssertCheck(result == 0, "Verify property value was set, got: %d", result); @@ -38,7 +38,7 @@ static int properties_testBasic(void *arg) for (i = 0; i < 10; ++i) { SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i); - result = SDL_SetProperty(props, key, NULL, NULL, NULL); + result = SDL_SetProperty(props, key, NULL); SDLTest_AssertPass("Call to SDL_SetProperty(NULL)"); SDLTest_AssertCheck(result == 0, "Verify property value was set, got: %d", result); @@ -71,8 +71,8 @@ static int properties_testCleanup(void *arg) SDLTest_AssertPass("Call to SDL_SetProperty(cleanup)"); count = 0; - SDL_SetProperty(props, "a", "0", cleanup, &count); - SDL_SetProperty(props, "a", NULL, cleanup, &count); + SDL_SetPropertyWithCleanup(props, "a", "0", cleanup, &count); + SDL_SetPropertyWithCleanup(props, "a", NULL, cleanup, &count); SDLTest_AssertCheck(count == 1, "Verify cleanup for deleting property, got %d, expected 1", count); @@ -81,7 +81,7 @@ static int properties_testCleanup(void *arg) for (i = 0; i < 10; ++i) { SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i); SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i); - SDL_SetProperty(props, key, expected_value, cleanup, &count); + SDL_SetPropertyWithCleanup(props, key, expected_value, cleanup, &count); } SDL_DestroyProperties(props); SDLTest_AssertCheck(count == 10, @@ -104,11 +104,11 @@ static int properties_thread(void *arg) while (!data->done) { SDL_LockProperties(data->props); - SDL_SetProperty(data->props, "a", "thread_loop", NULL, NULL); + SDL_SetProperty(data->props, "a", "thread_loop"); SDL_UnlockProperties(data->props); } SDL_LockProperties(data->props); - SDL_SetProperty(data->props, "a", "thread_done", NULL, NULL); + SDL_SetProperty(data->props, "a", "thread_done"); SDL_UnlockProperties(data->props); return 0; } @@ -122,7 +122,7 @@ static int properties_testLocking(void *arg) data.done = SDL_FALSE; data.props = SDL_CreateProperties(); SDLTest_AssertPass("Setting property to 'init'"); - SDL_SetProperty(data.props, "a", "init", NULL, NULL); + SDL_SetProperty(data.props, "a", "init"); thread = SDL_CreateThread(properties_thread, "properties_thread", &data); if (thread) { SDLTest_AssertPass("Waiting for property to change to 'thread_loop'"); @@ -142,7 +142,7 @@ static int properties_testLocking(void *arg) SDLTest_AssertPass("Setting property to 'main'"); SDL_LockProperties(data.props); - SDL_SetProperty(data.props, "a", "main", NULL, NULL); + SDL_SetProperty(data.props, "a", "main"); SDL_Delay(100); value = SDL_GetProperty(data.props, "a"); SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "main") == 0, diff --git a/test/testautomation_video.c b/test/testautomation_video.c index d45a9a40f..a05d90267 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -1498,7 +1498,7 @@ static int video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); /* Set data */ - SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s)", name, userdata); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); @@ -1514,7 +1514,7 @@ static int video_getSetWindowData(void *arg) /* Set data again twice */ for (iteration = 1; iteration <= 2; iteration++) { - SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [iteration %d]", name, userdata, iteration); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); @@ -1527,14 +1527,14 @@ static int video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); /* Set data with new data */ - SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata2, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata2); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata]", name, userdata2); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); /* Set data with new data again */ - SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata2, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata2); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [new userdata again]", name, userdata2); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); @@ -1547,14 +1547,14 @@ static int video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); /* Set data with NULL to clear */ - SDL_SetProperty(SDL_GetWindowProperties(window), name, NULL, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, NULL); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL)", name); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata2, userdata2) == 0, "Validate that userdata2 was not changed, expected: %s, got: %s", referenceUserdata2, userdata2); /* Set data with NULL to clear again */ - SDL_SetProperty(SDL_GetWindowProperties(window), name, NULL, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, NULL); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,NULL) [again]", name); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); @@ -1573,7 +1573,7 @@ static int video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName2, name2) == 0, "Validate that name2 was not changed, expected: %s, got: %s", referenceName2, name2); /* Set data (again) */ - SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), name, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(...%s,%s) [again, after clear]", name, userdata); SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); SDLTest_AssertCheck(SDL_strcmp(referenceUserdata, userdata) == 0, "Validate that userdata was not changed, expected: %s, got: %s", referenceUserdata, userdata); @@ -1585,22 +1585,22 @@ static int video_getSetWindowData(void *arg) SDLTest_AssertCheck(SDL_strcmp(referenceName, name) == 0, "Validate that name was not changed, expected: %s, got: %s", referenceName, name); /* Set data with NULL name, valid userdata */ - SDL_SetProperty(SDL_GetWindowProperties(window), NULL, userdata, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), NULL, userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL)"); checkInvalidParameterError(); /* Set data with empty name, valid userdata */ - SDL_SetProperty(SDL_GetWindowProperties(window), "", userdata, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), "", userdata); SDLTest_AssertPass("Call to SDL_SetWindowData(name='')"); checkInvalidParameterError(); /* Set data with NULL name, NULL userdata */ - SDL_SetProperty(SDL_GetWindowProperties(window), NULL, NULL, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), NULL, NULL); SDLTest_AssertPass("Call to SDL_SetWindowData(name=NULL,userdata=NULL)"); checkInvalidParameterError(); /* Set data with empty name, NULL userdata */ - SDL_SetProperty(SDL_GetWindowProperties(window), "", NULL, NULL, NULL); + SDL_SetProperty(SDL_GetWindowProperties(window), "", NULL); SDLTest_AssertPass("Call to SDL_SetWindowData(name='',userdata=NULL)"); checkInvalidParameterError(); diff --git a/test/testffmpeg.c b/test/testffmpeg.c index ecaad773a..519ae466f 100644 --- a/test/testffmpeg.c +++ b/test/testffmpeg.c @@ -464,7 +464,7 @@ static SDL_bool GetTextureForMemoryFrame(AVFrame *frame, SDL_Texture **texture) SDL_OutOfMemory(); return SDL_FALSE; } - SDL_SetProperty(props, SWS_CONTEXT_CONTAINER_PROPERTY, sws_container, FreeSwsContextContainer, NULL); + SDL_SetPropertyWithCleanup(props, SWS_CONTEXT_CONTAINER_PROPERTY, sws_container, FreeSwsContextContainer, NULL); } sws_container->context = sws_getCachedContext(sws_container->context, frame->width, frame->height, frame->format, frame->width, frame->height, AV_PIX_FMT_BGRA, SWS_POINT, NULL, NULL, NULL); if (sws_container->context) {