Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/scripts/deps/sdl3-wgi-roinitialize.patch
5179 views
1
From 54c2f2c3f781db2e5593d44aa108f7043fc19baa Mon Sep 17 00:00:00 2001
2
From: Sam Lantinga <[email protected]>
3
Date: Wed, 8 Oct 2025 13:15:48 -0700
4
Subject: [PATCH] Only call WIN_RoUninitialize() if WIN_RoInitialize()
5
succeeded
6
7
Fixes https://github.com/libsdl-org/SDL/issues/14178
8
9
(cherry picked from commit 7914bdb7ea14ee5109d50df857c8dfc69a28a62d)
10
---
11
src/joystick/windows/SDL_windows_gaming_input.c | 6 +++++-
12
1 file changed, 5 insertions(+), 1 deletion(-)
13
14
diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c
15
index 11ee2243b7683..5f9435e34a570 100644
16
--- a/src/joystick/windows/SDL_windows_gaming_input.c
17
+++ b/src/joystick/windows/SDL_windows_gaming_input.c
18
@@ -69,6 +69,7 @@ typedef PCWSTR(WINAPI *WindowsGetStringRawBuffer_t)(HSTRING string, UINT32 *leng
19
20
static struct
21
{
22
+ bool ro_initialized;
23
CoIncrementMTAUsage_t CoIncrementMTAUsage;
24
RoGetActivationFactory_t RoGetActivationFactory;
25
WindowsCreateStringReference_t WindowsCreateStringReference;
26
@@ -592,6 +593,7 @@ static bool WGI_JoystickInit(void)
27
if (FAILED(WIN_RoInitialize())) {
28
return SDL_SetError("RoInitialize() failed");
29
}
30
+ wgi.ro_initialized = true;
31
32
#define RESOLVE(x) wgi.x = (x##_t)WIN_LoadComBaseFunction(#x); if (!wgi.x) return WIN_SetError("GetProcAddress failed for " #x);
33
RESOLVE(CoIncrementMTAUsage);
34
@@ -1002,7 +1004,9 @@ static void WGI_JoystickQuit(void)
35
__x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_Release(wgi.controller_statics);
36
}
37
38
- WIN_RoUninitialize();
39
+ if (wgi.ro_initialized) {
40
+ WIN_RoUninitialize();
41
+ }
42
43
SDL_zero(wgi);
44
}
45
46