Path: blob/master/scripts/deps/sdl3-wgi-roinitialize.patch
5179 views
From 54c2f2c3f781db2e5593d44aa108f7043fc19baa Mon Sep 17 00:00:00 20011From: Sam Lantinga <[email protected]>2Date: Wed, 8 Oct 2025 13:15:48 -07003Subject: [PATCH] Only call WIN_RoUninitialize() if WIN_RoInitialize()4succeeded56Fixes https://github.com/libsdl-org/SDL/issues/1417878(cherry picked from commit 7914bdb7ea14ee5109d50df857c8dfc69a28a62d)9---10src/joystick/windows/SDL_windows_gaming_input.c | 6 +++++-111 file changed, 5 insertions(+), 1 deletion(-)1213diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c14index 11ee2243b7683..5f9435e34a570 10064415--- a/src/joystick/windows/SDL_windows_gaming_input.c16+++ b/src/joystick/windows/SDL_windows_gaming_input.c17@@ -69,6 +69,7 @@ typedef PCWSTR(WINAPI *WindowsGetStringRawBuffer_t)(HSTRING string, UINT32 *leng1819static struct20{21+ bool ro_initialized;22CoIncrementMTAUsage_t CoIncrementMTAUsage;23RoGetActivationFactory_t RoGetActivationFactory;24WindowsCreateStringReference_t WindowsCreateStringReference;25@@ -592,6 +593,7 @@ static bool WGI_JoystickInit(void)26if (FAILED(WIN_RoInitialize())) {27return SDL_SetError("RoInitialize() failed");28}29+ wgi.ro_initialized = true;3031#define RESOLVE(x) wgi.x = (x##_t)WIN_LoadComBaseFunction(#x); if (!wgi.x) return WIN_SetError("GetProcAddress failed for " #x);32RESOLVE(CoIncrementMTAUsage);33@@ -1002,7 +1004,9 @@ static void WGI_JoystickQuit(void)34__x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_Release(wgi.controller_statics);35}3637- WIN_RoUninitialize();38+ if (wgi.ro_initialized) {39+ WIN_RoUninitialize();40+ }4142SDL_zero(wgi);43}444546