mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +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/registermetadata.h"
|
||||||
#include "blackcore/setupreader.h"
|
#include "blackcore/setupreader.h"
|
||||||
#include "blackcore/webdataservices.h"
|
#include "blackcore/webdataservices.h"
|
||||||
|
#include "blackcore/inputmanager.h"
|
||||||
#include "blackmisc/atomicfile.h"
|
#include "blackmisc/atomicfile.h"
|
||||||
#include "blackmisc/applicationinfo.h"
|
#include "blackmisc/applicationinfo.h"
|
||||||
#include "blackmisc/datacache.h"
|
#include "blackmisc/datacache.h"
|
||||||
@@ -975,6 +976,10 @@ namespace BlackCore
|
|||||||
// info that we will shutdown
|
// info that we will shutdown
|
||||||
emit this->aboutToShutdown();
|
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
|
// mark as shutdown
|
||||||
if (m_networkWatchDog) { m_networkWatchDog->gracefulShutdown(); }
|
if (m_networkWatchDog) { m_networkWatchDog->gracefulShutdown(); }
|
||||||
m_shutdown = true;
|
m_shutdown = true;
|
||||||
|
|||||||
@@ -129,6 +129,12 @@ namespace BlackCore
|
|||||||
m_lastCombination = combination;
|
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)
|
int CInputManager::bindImpl(const QString &action, QObject *receiver, std::function<void (bool)> function)
|
||||||
{
|
{
|
||||||
static int index = 0;
|
static int index = 0;
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ namespace BlackCore
|
|||||||
//! Triggers a key event manually and calls the registered functions.
|
//! Triggers a key event manually and calls the registered functions.
|
||||||
void triggerKey(const BlackMisc::Input::CHotkeyCombination &combination, bool isPressed);
|
void triggerKey(const BlackMisc::Input::CHotkeyCombination &combination, bool isPressed);
|
||||||
|
|
||||||
|
//! Releases all devices
|
||||||
|
void releaseDevices();
|
||||||
|
|
||||||
//! Creates a native keyboard handler object
|
//! Creates a native keyboard handler object
|
||||||
static CInputManager *instance();
|
static CInputManager *instance();
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ namespace BlackInput
|
|||||||
|
|
||||||
CJoystickWindows::~CJoystickWindows()
|
CJoystickWindows::~CJoystickWindows()
|
||||||
{
|
{
|
||||||
|
m_joystickDevices.clear();
|
||||||
|
m_directInput.reset();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ namespace BlackInput
|
|||||||
ATOM helperWindowClass = 0;
|
ATOM helperWindowClass = 0;
|
||||||
HWND helperWindow = nullptr;
|
HWND helperWindow = nullptr;
|
||||||
|
|
||||||
|
const TCHAR *helperWindowClassName = TEXT("HelperWindow");
|
||||||
|
const TCHAR *helperWindowName = TEXT("JoystickCatcherWindow");
|
||||||
|
|
||||||
DirectInput8Ptr m_directInput; //!< DirectInput object
|
DirectInput8Ptr m_directInput; //!< DirectInput object
|
||||||
QVector<CJoystickDevice *> m_joystickDevices; //!< Joystick devices
|
QVector<CJoystickDevice *> m_joystickDevices; //!< Joystick devices
|
||||||
|
|
||||||
BlackMisc::Input::CHotkeyCombination m_buttonCombination;
|
BlackMisc::Input::CHotkeyCombination m_buttonCombination;
|
||||||
|
|
||||||
const TCHAR *helperWindowClassName = TEXT("HelperWindow");
|
|
||||||
const TCHAR *helperWindowName = TEXT("JoystickCatcherWindow");
|
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user