mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-28 15:39:10 +00:00
SDL_AddHintCallback() now returns a standard int result instead of void
Fixes https://github.com/libsdl-org/SDL/issues/7035
This commit is contained in:
parent
fde78d12f2
commit
5feebcdce0
4 changed files with 15 additions and 15 deletions
|
@ -272,6 +272,8 @@ functionality to your app and aid migration. That is located in the
|
||||||
|
|
||||||
## SDL_hints.h
|
## SDL_hints.h
|
||||||
|
|
||||||
|
SDL_AddHintCallback() now returns a standard int result instead of void, returning 0 if the function succeeds or a negative error code if there was an error.
|
||||||
|
|
||||||
The following hints have been removed:
|
The following hints have been removed:
|
||||||
* SDL_HINT_IDLE_TIMER_DISABLED (use SDL_DisableScreenSaver instead)
|
* SDL_HINT_IDLE_TIMER_DISABLED (use SDL_DisableScreenSaver instead)
|
||||||
* SDL_HINT_VIDEO_X11_FORCE_EGL (use SDL_HINT_VIDEO_FORCE_EGL instead)
|
* SDL_HINT_VIDEO_X11_FORCE_EGL (use SDL_HINT_VIDEO_FORCE_EGL instead)
|
||||||
|
|
|
@ -2525,14 +2525,16 @@ typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const
|
||||||
* \param callback An SDL_HintCallback function that will be called when the
|
* \param callback An SDL_HintCallback function that will be called when the
|
||||||
* hint value changes
|
* hint value changes
|
||||||
* \param userdata a pointer to pass to the callback function
|
* \param userdata a pointer to pass to the callback function
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
* \sa SDL_DelHintCallback
|
* \sa SDL_DelHintCallback
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name,
|
extern DECLSPEC int SDLCALL SDL_AddHintCallback(const char *name,
|
||||||
SDL_HintCallback callback,
|
SDL_HintCallback callback,
|
||||||
void *userdata);
|
void *userdata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a function watching a particular hint.
|
* Remove a function watching a particular hint.
|
||||||
|
|
|
@ -195,27 +195,24 @@ SDL_GetHintBoolean(const char *name, SDL_bool default_value)
|
||||||
return SDL_GetStringBoolean(hint, default_value);
|
return SDL_GetStringBoolean(hint, default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||||
{
|
{
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
SDL_HintWatch *entry;
|
SDL_HintWatch *entry;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
if (name == NULL || !*name) {
|
if (name == NULL || !*name) {
|
||||||
SDL_InvalidParamError("name");
|
return SDL_InvalidParamError("name");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
SDL_InvalidParamError("callback");
|
return SDL_InvalidParamError("callback");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DelHintCallback(name, callback, userdata);
|
SDL_DelHintCallback(name, callback, userdata);
|
||||||
|
|
||||||
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
||||||
if (entry == NULL) {
|
if (entry == NULL) {
|
||||||
SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
entry->callback = callback;
|
entry->callback = callback;
|
||||||
entry->userdata = userdata;
|
entry->userdata = userdata;
|
||||||
|
@ -229,16 +226,14 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
|
||||||
/* Need to add a hint entry for this watcher */
|
/* Need to add a hint entry for this watcher */
|
||||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||||
if (hint == NULL) {
|
if (hint == NULL) {
|
||||||
SDL_OutOfMemory();
|
|
||||||
SDL_free(entry);
|
SDL_free(entry);
|
||||||
return;
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
hint->name = SDL_strdup(name);
|
hint->name = SDL_strdup(name);
|
||||||
if (!hint->name) {
|
if (!hint->name) {
|
||||||
SDL_free(entry);
|
SDL_free(entry);
|
||||||
SDL_free(hint);
|
SDL_free(hint);
|
||||||
SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
hint->value = NULL;
|
hint->value = NULL;
|
||||||
hint->priority = SDL_HINT_DEFAULT;
|
hint->priority = SDL_HINT_DEFAULT;
|
||||||
|
@ -254,6 +249,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
|
||||||
/* Now call it with the current value */
|
/* Now call it with the current value */
|
||||||
value = SDL_GetHint(name);
|
value = SDL_GetHint(name);
|
||||||
callback(userdata, name, value, value);
|
callback(userdata, name, value, value);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||||
|
|
|
@ -119,7 +119,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_IsDeXMode,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),)
|
SDL_DYNAPI_PROC(void,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),)
|
||||||
SDL_DYNAPI_PROC(int,SDL_AddGamepadMapping,(const char *a),(a),return)
|
SDL_DYNAPI_PROC(int,SDL_AddGamepadMapping,(const char *a),(a),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_AddGamepadMappingsFromRW,(SDL_RWops *a, int b),(a,b),return)
|
SDL_DYNAPI_PROC(int,SDL_AddGamepadMappingsFromRW,(SDL_RWops *a, int b),(a,b),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_AddHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),)
|
SDL_DYNAPI_PROC(int,SDL_AddHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimer,(Uint32 a, SDL_TimerCallback b, void *c),(a,b,c),return)
|
SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimer,(Uint32 a, SDL_TimerCallback b, void *c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(SDL_RWops*,SDL_CreateRW,(void),(),return)
|
SDL_DYNAPI_PROC(SDL_RWops*,SDL_CreateRW,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_atomic_t *a, int b),(a,b),return)
|
SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_atomic_t *a, int b),(a,b),return)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue