mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-08 04:18:14 +00:00
Set the hint value before calling hint callbacks
This allows the hint callbacks to perform more complicated logic involving multiple hints without worrying about which hint has been changed.
This commit is contained in:
@@ -65,14 +65,18 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
|
||||
}
|
||||
if (hint->value != value &&
|
||||
(value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
|
||||
char *old_value = hint->value;
|
||||
|
||||
hint->value = value ? SDL_strdup(value) : NULL;
|
||||
for (entry = hint->callbacks; entry;) {
|
||||
/* Save the next entry in case this one is deleted */
|
||||
SDL_HintWatch *next = entry->next;
|
||||
entry->callback(entry->userdata, name, hint->value, value);
|
||||
entry->callback(entry->userdata, name, old_value, value);
|
||||
entry = next;
|
||||
}
|
||||
SDL_free(hint->value);
|
||||
hint->value = value ? SDL_strdup(value) : NULL;
|
||||
if (old_value) {
|
||||
SDL_free(old_value);
|
||||
}
|
||||
}
|
||||
hint->priority = priority;
|
||||
return SDL_TRUE;
|
||||
|
Reference in New Issue
Block a user