Bläddra i källkod

Added an error message when SDL_GetWindowFromID() fails

Sam Lantinga 8 månader sedan
förälder
incheckning
2c1d40a9eb
1 ändrade filer med 7 tillägg och 3 borttagningar
  1. 7 3
      src/video/SDL_video.c

+ 7 - 3
src/video/SDL_video.c

@@ -2649,13 +2649,17 @@ SDL_Window *SDL_GetWindowFromID(SDL_WindowID id)
     SDL_Window *window;
 
     if (!_this) {
+        SDL_UninitializedVideo();
         return NULL;
     }
-    for (window = _this->windows; window; window = window->next) {
-        if (window->id == id) {
-            return window;
+    if (id) {
+        for (window = _this->windows; window; window = window->next) {
+            if (window->id == id) {
+                return window;
+            }
         }
     }
+    SDL_SetError("Invalid window ID");                                 \
     return NULL;
 }