From 34512371bb3269c3d3b8c863978deb2eedce7871 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 18 Apr 2015 02:46:56 -0700 Subject: [PATCH] Qt: Fix crash if no axes are found --- src/platform/qt/InputController.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index 54289dc7f..3c59d7df2 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -233,6 +233,9 @@ void InputController::recalibrateAxes() { SDL_Joystick* joystick = m_sdlPlayer.joystick; SDL_JoystickUpdate(); int numAxes = SDL_JoystickNumAxes(joystick); + if (numAxes < 1) { + return; + } m_deadzones.resize(numAxes); int i; for (i = 0; i < numAxes; ++i) { @@ -244,8 +247,11 @@ QSet> InputController::activeGamepadAxes SDL_Joystick* joystick = m_sdlPlayer.joystick; SDL_JoystickUpdate(); int numAxes = SDL_JoystickNumAxes(joystick); - m_deadzones.resize(numAxes); QSet> activeAxes; + if (numAxes < 1) { + return activeAxes; + } + m_deadzones.resize(numAxes); int i; for (i = 0; i < numAxes; ++i) { int32_t axis = SDL_JoystickGetAxis(joystick, i);