SDL: Fixed crash if app delegate method is called when SDL isn't initialized

From d211da75ac635641c7872af12d460cb25ad5f17b Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 25 Feb 2024 13:38:47 -0800
Subject: [PATCH] Fixed crash if app delegate method is called when SDL isn't
 initialized

---
 src/video/cocoa/SDL_cocoaevents.m | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m
index daaa0ba33b99..81f086cea30d 100644
--- a/src/video/cocoa/SDL_cocoaevents.m
+++ b/src/video/cocoa/SDL_cocoaevents.m
@@ -284,7 +284,10 @@ - (void)focusSomeWindow:(NSNotification *)aNotification
 
 - (void)screenParametersChanged:(NSNotification *)aNotification
 {
-    Cocoa_UpdateDisplays(SDL_GetVideoDevice());
+    SDL_VideoDevice *device = SDL_GetVideoDevice();
+    if (device) {
+        Cocoa_UpdateDisplays(device);
+    }
 }
 
 - (void)localeDidChange:(NSNotification *)notification