From 2c1d40a9ebc670b6c2b2d3127811e167749da836 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 2 Aug 2024 18:43:24 -0700
Subject: [PATCH] Added an error message when SDL_GetWindowFromID() fails
---
src/video/SDL_video.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 5dfe7dabd7038..47677944d7a4a 100644
--- a/src/video/SDL_video.c
+++ b/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;
}