Only destroy dinput if non-NULL.

This commit is contained in:
Themaister 2014-01-16 08:17:20 +01:00
parent 8b5e950eef
commit 682bd74a28
1 changed files with 31 additions and 29 deletions

View File

@ -475,6 +475,7 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa
}
case WM_DEVICECHANGE:
{
if (di->joypad)
di->joypad->destroy();
di->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
break;
@ -491,6 +492,7 @@ static void dinput_free(void *data)
if (di)
{
g_ctx = NULL; // Prevent a joypad driver to kill our context prematurely.
if (di->joypad)
di->joypad->destroy();
g_ctx = hold_ctx;