mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
Release input devices when application is shutdown
If they are released with the deallocation of CInputManager, we might run into global deallocation hell. Also on Windows release all DirectX devices before COM library is closed. ref T391
This commit is contained in:
committed by
Klaus Basan
parent
910b536dee
commit
c42900f959
@@ -19,6 +19,7 @@
|
||||
#include "blackcore/registermetadata.h"
|
||||
#include "blackcore/setupreader.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackcore/inputmanager.h"
|
||||
#include "blackmisc/atomicfile.h"
|
||||
#include "blackmisc/applicationinfo.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
@@ -975,6 +976,10 @@ namespace BlackCore
|
||||
// info that we will shutdown
|
||||
emit this->aboutToShutdown();
|
||||
|
||||
// Release all input devices to not cause any accidental hotkey triggers anymore.
|
||||
// This is also necessary to properly free platform specific instances at a defined point in time.
|
||||
CInputManager::instance()->releaseDevices();
|
||||
|
||||
// mark as shutdown
|
||||
if (m_networkWatchDog) { m_networkWatchDog->gracefulShutdown(); }
|
||||
m_shutdown = true;
|
||||
|
||||
@@ -129,6 +129,12 @@ namespace BlackCore
|
||||
m_lastCombination = combination;
|
||||
}
|
||||
|
||||
void CInputManager::releaseDevices()
|
||||
{
|
||||
m_keyboard.reset();
|
||||
m_joystick.reset();
|
||||
}
|
||||
|
||||
int CInputManager::bindImpl(const QString &action, QObject *receiver, std::function<void (bool)> function)
|
||||
{
|
||||
static int index = 0;
|
||||
|
||||
@@ -87,6 +87,9 @@ namespace BlackCore
|
||||
//! Triggers a key event manually and calls the registered functions.
|
||||
void triggerKey(const BlackMisc::Input::CHotkeyCombination &combination, bool isPressed);
|
||||
|
||||
//! Releases all devices
|
||||
void releaseDevices();
|
||||
|
||||
//! Creates a native keyboard handler object
|
||||
static CInputManager *instance();
|
||||
|
||||
|
||||
@@ -165,6 +165,8 @@ namespace BlackInput
|
||||
|
||||
CJoystickWindows::~CJoystickWindows()
|
||||
{
|
||||
m_joystickDevices.clear();
|
||||
m_directInput.reset();
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -134,13 +134,13 @@ namespace BlackInput
|
||||
ATOM helperWindowClass = 0;
|
||||
HWND helperWindow = nullptr;
|
||||
|
||||
const TCHAR *helperWindowClassName = TEXT("HelperWindow");
|
||||
const TCHAR *helperWindowName = TEXT("JoystickCatcherWindow");
|
||||
|
||||
DirectInput8Ptr m_directInput; //!< DirectInput object
|
||||
QVector<CJoystickDevice *> m_joystickDevices; //!< Joystick devices
|
||||
|
||||
BlackMisc::Input::CHotkeyCombination m_buttonCombination;
|
||||
|
||||
const TCHAR *helperWindowClassName = TEXT("HelperWindow");
|
||||
const TCHAR *helperWindowName = TEXT("JoystickCatcherWindow");
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user