From e1b1ae449b057cfe923f84e35874e5bdf187ba28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 16 Jan 2024 14:32:42 +0100 Subject: [PATCH] Don't crash after mapping analog speed to a stick. Fixes #18689 --- Core/KeyMap.cpp | 10 +++++++--- UI/GameSettingsScreen.cpp | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index f52072bb64..d9af549746 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -553,12 +553,16 @@ bool InputMappingsFromPspButtonNoLock(int btn, std::vector *m return false; } bool mapped = false; - mappings->clear(); + if (mappings) { + mappings->clear(); + } for (auto &iter2 : iter->second) { bool ignore = ignoreMouse && iter2.HasMouse(); - if (mappings && !ignore) { + if (!ignore) { mapped = true; - mappings->push_back(iter2); + if (mappings) { + mappings->push_back(iter2); + } } } return mapped; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 6dd0fb1d21..f1187c1467 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1527,6 +1527,7 @@ void GameSettingsScreen::dialogFinished(const Screen *dialog, DialogResult resul RecreateViews(); } + // Show/hide the Analog Alternative Speed as appropriate - need to recreate views if this changed. bool mapped = KeyMap::InputMappingsFromPspButton(VIRTKEY_SPEED_ANALOG, nullptr, true); if (mapped != analogSpeedMapped_) { analogSpeedMapped_ = mapped;