SDL: Fixed crash at shutdown on Windows

From c3ce216c4daa22bc38117ef833486ba885bb6f20 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 1 Apr 2025 14:54:53 -0700
Subject: [PATCH] Fixed crash at shutdown on Windows

The taskbar list is invalid after OleUninitialize(), so make sure we clean it up first.

Also don't bother creating the taskbar list if we don't have any progress state
---
 src/video/windows/SDL_windowsvideo.c  | 12 ++++++------
 src/video/windows/SDL_windowswindow.c |  4 ++++
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index bdfde9ce3404f..25dea1f3b56fd 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -583,12 +583,6 @@ void WIN_VideoQuit(SDL_VideoDevice *_this)
     WIN_QuitKeyboard(_this);
     WIN_QuitMouse(_this);
 
-    if (data->oleinitialized) {
-        OleUninitialize();
-        data->oleinitialized = false;
-    }
-#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
-
 #if defined(HAVE_SHOBJIDL_CORE_H)
     if (data->taskbar_list) {
         IUnknown_Release(data->taskbar_list);
@@ -596,6 +590,12 @@ void WIN_VideoQuit(SDL_VideoDevice *_this)
     }
 #endif
 
+    if (data->oleinitialized) {
+        OleUninitialize();
+        data->oleinitialized = false;
+    }
+#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
+
     if (data->coinitialized) {
         WIN_CoUninitialize();
         data->coinitialized = false;
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 3eca533a37d5a..c6b5fc7300e86 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -2253,6 +2253,10 @@ bool WIN_ApplyWindowProgress(SDL_VideoDevice *_this, SDL_Window* window)
         return true;
     }
 
+    if (window->progress_state == SDL_PROGRESS_STATE_NONE && !data->videodata->taskbar_list) {
+        return true;
+    }
+
     ITaskbarList3 *taskbar_list = GetTaskbarList(window);
     if (!taskbar_list) {
         return false;