Skip to content

Commit

Permalink
WGI: Only call RoUninitialize() if RoInitialize() succeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
cgutman authored and slouken committed Apr 21, 2022
1 parent 00b2e10 commit 145824f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/joystick/windows/SDL_windows_gaming_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static struct {
EventRegistrationToken controller_added_token;
EventRegistrationToken controller_removed_token;
int controller_count;
SDL_bool ro_initialized;
WindowsGamingInputControllerState *controllers;
} wgi;

Expand Down Expand Up @@ -443,6 +444,7 @@ WGI_JoystickInit(void)
if (FAILED(WIN_RoInitialize())) {
return SDL_SetError("RoInitialize() failed");
}
wgi.ro_initialized = SDL_TRUE;

#ifndef __WINRT__
{
Expand Down Expand Up @@ -871,9 +873,12 @@ WGI_JoystickQuit(void)
__x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_remove_RawGameControllerRemoved(wgi.statics, wgi.controller_removed_token);
__x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_Release(wgi.statics);
}
SDL_zero(wgi);

WIN_RoUninitialize();
if (wgi.ro_initialized) {
WIN_RoUninitialize();
}

SDL_zero(wgi);
}

static SDL_bool
Expand Down

0 comments on commit 145824f

Please sign in to comment.