From 4b3d3bba48608d1be2ae141a6de508c88626ffc7 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 15 Oct 2018 12:12:17 +0200 Subject: [PATCH] Destroy DirectInput helper window during shutdown --- src/blackinput/win/joystickwindows.cpp | 14 ++++++++++++++ src/blackinput/win/joystickwindows.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/blackinput/win/joystickwindows.cpp b/src/blackinput/win/joystickwindows.cpp index 383e126ad..5ede8e32c 100644 --- a/src/blackinput/win/joystickwindows.cpp +++ b/src/blackinput/win/joystickwindows.cpp @@ -168,6 +168,7 @@ namespace BlackInput m_joystickDevices.clear(); m_directInput.reset(); CoUninitialize(); + destroyHelperWindow(); } void ReleaseDirectInput(IDirectInput8 *obj) @@ -252,6 +253,19 @@ namespace BlackInput return 0; } + void CJoystickWindows::destroyHelperWindow() + { + HINSTANCE hInstance = GetModuleHandle(nullptr); + + if (helperWindow == nullptr) { return; } + + DestroyWindow(helperWindow); + helperWindow = nullptr; + + UnregisterClass(helperWindowClassName, hInstance); + helperWindowClass = 0; + } + void CJoystickWindows::addJoystickDevice(const DIDEVICEINSTANCE *pdidInstance) { CJoystickDevice *device = new CJoystickDevice(m_directInput, pdidInstance, this); diff --git a/src/blackinput/win/joystickwindows.h b/src/blackinput/win/joystickwindows.h index e95583f8f..dd23dbc5a 100644 --- a/src/blackinput/win/joystickwindows.h +++ b/src/blackinput/win/joystickwindows.h @@ -123,6 +123,9 @@ namespace BlackInput //! Creates a hidden DI helper window int createHelperWindow(); + //! Destroys a hidden DI helper window + void destroyHelperWindow(); + //! Add new joystick device void addJoystickDevice(const DIDEVICEINSTANCE *pdidInstance);