all repos — mgba @ 298d5e968905c47be7748b6869add035db708dc5

mGBA Game Boy Advance Emulator

Qt: Fix input crashes when no game was loaded
Vicki Pfau vi@endrift.com
Wed, 12 Jul 2017 20:20:04 -0700
commit

298d5e968905c47be7748b6869add035db708dc5

parent

bcb1617a6996445faad0f5dede50bbd4d8d6f0b5

M src/platform/qt/GamepadAxisEvent.cppsrc/platform/qt/GamepadAxisEvent.cpp

@@ -20,7 +20,7 @@ , m_controller(controller)

, m_key(GBA_KEY_NONE) { ignore(); - if (controller) { + if (controller && controller->map()) { m_key = static_cast<GBAKey>(mInputMapAxis(controller->map(), type, axis, direction * INT_MAX)); } }
M src/platform/qt/GamepadButtonEvent.cppsrc/platform/qt/GamepadButtonEvent.cpp

@@ -19,7 +19,7 @@ , m_controller(controller)

, m_key(GBA_KEY_NONE) { ignore(); - if (controller) { + if (controller && controller->map()) { m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button)); } }
M src/platform/qt/GamepadHatEvent.cppsrc/platform/qt/GamepadHatEvent.cpp

@@ -20,7 +20,7 @@ , m_controller(controller)

, m_key(GBA_KEY_NONE) { ignore(); - if (controller) { + if (controller && controller->map()) { m_key = static_cast<GBAKey>(mInputMapHat(controller->map(), type, hatId, direction)); } }
M src/platform/qt/input/InputController.cppsrc/platform/qt/input/InputController.cpp

@@ -366,6 +366,9 @@ #endif

} const mInputMap* InputController::map() { + if (!m_activeKeyInfo) { + return nullptr; + } return &m_inputMap; }