From 34ec93670ad408ae195bc376c6f692c0023c1d26 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 7 Apr 2017 16:56:15 -0700 Subject: [PATCH] Qt: Fix out of bounds keys and saving null maps --- src/platform/qt/InputController.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index bc287cec9..bd8947b17 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -184,6 +184,9 @@ void InputController::saveConfiguration() { void InputController::saveConfiguration(uint32_t type) { for (auto& inputMap : m_inputMaps) { + if (!inputMap.info) { + continue; + } mInputMapSave(&inputMap, type, m_config->input()); } m_config->write(); @@ -445,6 +448,9 @@ QSet> InputController::activeGamepadAxes } void InputController::bindKey(mPlatform platform, uint32_t type, int key, int coreKey) { + if (m_inputMaps.find(platform) == m_inputMaps.end() || coreKey >= m_inputMaps[platform].info->nKeys) { + return; + } QModelIndex index = m_inputModel->index(coreKey, 0, m_inputMenuIndices[platform]); bool signalsBlocked = m_inputModel->blockSignals(true); if (type != KEYBOARD) { @@ -457,6 +463,9 @@ void InputController::bindKey(mPlatform platform, uint32_t type, int key, int co } void InputController::bindAxis(mPlatform platform, uint32_t type, int axis, GamepadAxisEvent::Direction direction, int key) { + if (m_inputMaps.find(platform) == m_inputMaps.end() || key >= m_inputMaps[platform].info->nKeys) { + return; + } QModelIndex index = m_inputModel->index(key, 0, m_inputMenuIndices[platform]); bool signalsBlocked = m_inputModel->blockSignals(true); m_inputModel->updateAxis(index, axis, direction); @@ -520,6 +529,9 @@ QSet> InputController::activeGamepadHats( } void InputController::bindHat(mPlatform platform, uint32_t type, int hat, GamepadHatEvent::Direction direction, int coreKey) { + if (m_inputMaps.find(platform) == m_inputMaps.end() || coreKey >= m_inputMaps[platform].info->nKeys) { + return; + } QModelIndex index = m_inputModel->index(coreKey, 0, m_inputMenuIndices[platform]); //m_inputModel->updateHat(index, hat, direction);