mirror of https://github.com/encounter/SDL.git
rawinput: Only access SDL_RAWINPUT_mutex if initialized
We can also ditch the lock in RAWINPUT_JoystickQuit() now that the joystick subsystem quits drivers in reverse order. There's no chance of a racing call to RAWINPUT_WindowProc() anymore.
This commit is contained in:
parent
1237142be3
commit
881a674926
|
@ -1857,9 +1857,9 @@ RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
LRESULT result = -1;
|
LRESULT result = -1;
|
||||||
|
|
||||||
SDL_LockMutex(SDL_RAWINPUT_mutex);
|
|
||||||
|
|
||||||
if (SDL_RAWINPUT_inited) {
|
if (SDL_RAWINPUT_inited) {
|
||||||
|
SDL_LockMutex(SDL_RAWINPUT_mutex);
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INPUT_DEVICE_CHANGE:
|
case WM_INPUT_DEVICE_CHANGE:
|
||||||
{
|
{
|
||||||
|
@ -1903,9 +1903,9 @@ RAWINPUT_WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
result = 0;
|
result = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SDL_UnlockMutex(SDL_RAWINPUT_mutex);
|
SDL_UnlockMutex(SDL_RAWINPUT_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -1920,8 +1920,6 @@ RAWINPUT_JoystickQuit(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockMutex(SDL_RAWINPUT_mutex);
|
|
||||||
|
|
||||||
while (SDL_RAWINPUT_devices) {
|
while (SDL_RAWINPUT_devices) {
|
||||||
RAWINPUT_DelDevice(SDL_RAWINPUT_devices, SDL_FALSE);
|
RAWINPUT_DelDevice(SDL_RAWINPUT_devices, SDL_FALSE);
|
||||||
}
|
}
|
||||||
|
@ -1932,7 +1930,6 @@ RAWINPUT_JoystickQuit(void)
|
||||||
|
|
||||||
SDL_RAWINPUT_inited = SDL_FALSE;
|
SDL_RAWINPUT_inited = SDL_FALSE;
|
||||||
|
|
||||||
SDL_UnlockMutex(SDL_RAWINPUT_mutex);
|
|
||||||
SDL_DestroyMutex(SDL_RAWINPUT_mutex);
|
SDL_DestroyMutex(SDL_RAWINPUT_mutex);
|
||||||
SDL_RAWINPUT_mutex = NULL;
|
SDL_RAWINPUT_mutex = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue