mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Windows: Fixed crash if quitting without closing an XInput haptic device.
This commit is contained in:
parent
754067db7e
commit
1005c93402
@ -939,20 +939,32 @@ SDL_SYS_HapticQuit(void)
|
|||||||
{
|
{
|
||||||
SDL_hapticlist_item *item;
|
SDL_hapticlist_item *item;
|
||||||
SDL_hapticlist_item *next = NULL;
|
SDL_hapticlist_item *next = NULL;
|
||||||
|
SDL_Haptic *hapticitem = NULL;
|
||||||
|
|
||||||
if (loaded_xinput) {
|
extern SDL_Haptic *SDL_haptics;
|
||||||
WIN_UnloadXInputDLL();
|
for (hapticitem = SDL_haptics; hapticitem; hapticitem = hapticitem->next) {
|
||||||
loaded_xinput = SDL_FALSE;
|
if ((hapticitem->hwdata->bXInputHaptic) && (hapticitem->hwdata->thread)) {
|
||||||
|
/* we _have_ to stop the thread before we free the XInput DLL! */
|
||||||
|
hapticitem->hwdata->stopThread = 1;
|
||||||
|
SDL_WaitThread(hapticitem->hwdata->thread, NULL);
|
||||||
|
hapticitem->hwdata->thread = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (item = SDL_hapticlist; item; item = next) {
|
for (item = SDL_hapticlist; item; item = next) {
|
||||||
/* Opened and not closed haptics are leaked, this is on purpose.
|
/* Opened and not closed haptics are leaked, this is on purpose.
|
||||||
* Close your haptic devices after usage. */
|
* Close your haptic devices after usage. */
|
||||||
|
/* !!! FIXME: (...is leaking on purpose a good idea?) */
|
||||||
next = item->next;
|
next = item->next;
|
||||||
SDL_free(item->name);
|
SDL_free(item->name);
|
||||||
SDL_free(item);
|
SDL_free(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loaded_xinput) {
|
||||||
|
WIN_UnloadXInputDLL();
|
||||||
|
loaded_xinput = SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (dinput != NULL) {
|
if (dinput != NULL) {
|
||||||
IDirectInput8_Release(dinput);
|
IDirectInput8_Release(dinput);
|
||||||
dinput = NULL;
|
dinput = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user