소스 검색

Allow environment hint overrides before hints are initialized

Fixes https://github.com/libsdl-org/SDL/issues/10514
Sam Lantinga 8 달 전
부모
커밋
2b853121fe
1개의 변경된 파일10개의 추가작업 그리고 12개의 파일을 삭제
  1. 10 12
      src/SDL_hints.c

+ 10 - 12
src/SDL_hints.c

@@ -196,23 +196,21 @@ const char *SDL_GetHint(const char *name)
         return NULL;
     }
 
-    const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE);
-    if (!hints) {
-        return NULL;
-    }
-
     const char *retval = SDL_getenv(name);
 
-    SDL_LockProperties(hints);
+    const SDL_PropertiesID hints = GetHintProperties(SDL_FALSE);
+    if (hints) {
+        SDL_LockProperties(hints);
 
-    SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
-    if (hint) {
-        if (!retval || hint->priority == SDL_HINT_OVERRIDE) {
-            retval = SDL_GetPersistentString(hint->value);
+        SDL_Hint *hint = SDL_GetPointerProperty(hints, name, NULL);
+        if (hint) {
+            if (!retval || hint->priority == SDL_HINT_OVERRIDE) {
+                retval = SDL_GetPersistentString(hint->value);
+            }
         }
-    }
 
-    SDL_UnlockProperties(hints);
+        SDL_UnlockProperties(hints);
+    }
 
     return retval;
 }