From d5d238e525d345568b39bab918a474efb7ff6974 Mon Sep 17 00:00:00 2001 From: Jacob Walser Date: Fri, 27 Jan 2017 20:45:06 -0500 Subject: [PATCH] Always stopPolling joystick before stopping thread --- src/Joystick/JoystickManager.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Joystick/JoystickManager.cc b/src/Joystick/JoystickManager.cc index 97a0b10cc..eb9685bf6 100644 --- a/src/Joystick/JoystickManager.cc +++ b/src/Joystick/JoystickManager.cc @@ -84,16 +84,18 @@ void JoystickManager::_setActiveJoystickFromSettings(void) */ #endif + if (_activeJoystick && !newMap.contains(_activeJoystick->name())) { + qCDebug(JoystickManagerLog) << "Active joystick removed"; + setActiveJoystick(NULL); + } + // Check to see if our current mapping contains any joysticks that are not in the new mapping // If so, those joysticks have been unplugged, and need to be cleaned up QMap::iterator i; for (i = _name2JoystickMap.begin(); i != _name2JoystickMap.end(); ++i) { if (!newMap.contains(i.key())) { qCDebug(JoystickManagerLog) << "Releasing joystick:" << i.key(); - if (_activeJoystick && !newMap.contains(_activeJoystick->name())) { - qCDebug(JoystickManagerLog) << "\twas active"; - setActiveJoystick(NULL); - } + i.value()->stopPolling(); i.value()->wait(1000); i.value()->deleteLater(); } -- 2.22.0