Qt: Fix crash when editing shortcuts with none selected (fixes #1964)

This commit is contained in:
Vicki Pfau 2020-12-03 20:45:21 -08:00
parent 542404b7fa
commit e31de6b470
2 changed files with 4 additions and 3 deletions

View File

@ -77,6 +77,7 @@ Other fixes:
- Qt: Fix cancelling pausing before the frame ends
- Qt: Fix gamepad event dispatching (fixes mgba.io/i/1922)
- Qt: Pre-attach GDB stub when launching with -g (fixes mgba.io/i/1950)
- Qt: Fix crash when editing shortcuts with none selected (fixes mgba.io/i/1964)
- SM83: Simplify register pair access on big endian
- SM83: Disassemble STOP as one byte
- Wii: Fix crash on unloading irregularly sized GBA ROMs

View File

@ -87,7 +87,7 @@ void ShortcutView::clear() {
QModelIndex index = m_ui.shortcutTable->selectionModel()->currentIndex();
QString name = m_model->name(index);
const Shortcut* item = m_controller->shortcut(name);
if (!item->action()) {
if (!item || !item->action()) {
return;
}
if (m_ui.gamepadButton->isChecked()) {
@ -106,7 +106,7 @@ void ShortcutView::updateButton(int button) {
}
QString name = m_model->name(m_ui.shortcutTable->selectionModel()->currentIndex());
const Shortcut* item = m_controller->shortcut(name);
if (!item->action()) {
if (!item || !item->action()) {
return;
}
if (m_ui.gamepadButton->isChecked()) {
@ -122,7 +122,7 @@ void ShortcutView::updateAxis(int axis, int direction) {
}
QString name = m_model->name(m_ui.shortcutTable->selectionModel()->currentIndex());
const Shortcut* item = m_controller->shortcut(name);
if (!item->action()) {
if (!item || !item->action()) {
return;
}
m_controller->updateAxis(name, axis, static_cast<GamepadAxisEvent::Direction>(direction));