Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve behavior of SDL_SetHint(WithPriority) #5309

Merged
merged 2 commits into from Aug 10, 2022
Merged

Conversation

pionere
Copy link
Contributor

@pionere pionere commented Feb 5, 2022

Scenario 1. (overwrite hint temporary)

char* hint = SDL_GetHint(HINT_A);
hint = hint == NULL ? NULL : strdup(hint); // preserve previous hint
SDL_SetHint(HINT_A, "temp");               // overwrite hint
...
SDL_SetHint(HINT_A, hint);                 // restore hint
SDL_free(hint);
char* result = SDL_GetHint(HINT_A);
X Result
expected hint
currently hint == NULL ? "temp" : hint;
with PR hint

Scenario 2. (force suppress hint)

char* hint = SDL_GetHint(HINT_A);
SDL_SetHintWithPriority(HINT_A, NULL, SDL_HINT_OVERRIDE); // suppress hint (and env)
char* result = SDL_GetHint(HINT_A);
X Result
expected NULL
currently env == NULL ? (hint == NULL ? NULL : hint) : env;
with PR NULL

Scenario 3. (force suppress hint temporary)

char* hint = SDL_GetHint(HINT_A);
SDL_SetHintWithPriority(HINT_A, "temp", SDL_HINT_OVERRIDE);
...
SDL_SetHintWithPriority(HINT_A, NULL, SDL_HINT_OVERRIDE);
char* result = SDL_GetHint(HINT_A);
X Result
expected env ? env : NULL
currently "temp"
with PR NULL

To solve the last case, an explicit DelHint(WithPriority) function would be necessary...

@sezero
Copy link
Contributor

sezero commented Mar 24, 2022

Is this eligible for 2.0.22 (reviewed?) or should wait for later?

@slouken slouken added this to the 2.0.24 milestone Mar 24, 2022
@slouken
Copy link
Collaborator

slouken commented Apr 26, 2022

We need to decide whether a NULL value means clear the existing override or override with NULL. Here is a related bug: #5120

@slouken
Copy link
Collaborator

slouken commented Jun 7, 2022

@icculus, can you review this now that #5120 is fixed?

@icculus icculus added the early in milestone This change should be made early in the milestone for additional testing label Jun 7, 2022
@icculus icculus merged commit 7eb13c2 into libsdl-org:main Aug 10, 2022
@slouken
Copy link
Collaborator

slouken commented Aug 10, 2022

After discussion, we agreed that setting a NULL value means overriding with NULL, and we're adding a new API SDL_ResetHint() to take care of the ambiguity.

slouken added a commit that referenced this pull request Aug 10, 2022
Resolves question of how to clear an override hint raised by @pionere in #5309
PJB3005 pushed a commit to PJB3005/SDL that referenced this pull request Oct 5, 2022
PJB3005 pushed a commit to PJB3005/SDL that referenced this pull request Oct 5, 2022
Resolves question of how to clear an override hint raised by @pionere in libsdl-org#5309
@pionere pionere deleted the hints branch November 18, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
early in milestone This change should be made early in the milestone for additional testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants