From e6fb9325606f270dfb232912d85d9c6a78ca4502 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Tue, 19 Nov 2024 15:52:17 +0100 Subject: [PATCH] Controller: clear mapping pointer when unloading a mapping --- src/controllers/controller.h | 4 ++++ src/controllers/controllermanager.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/controllers/controller.h b/src/controllers/controller.h index 2c91e7d0ba7e..9d8ac370a1e3 100644 --- a/src/controllers/controller.h +++ b/src/controllers/controller.h @@ -81,6 +81,10 @@ class Controller : public QObject { template std::shared_ptr downcastAndTakeOwnership( std::shared_ptr&& pMapping) { + // When unsetting a mapping (select 'No mapping') we receive a nullptr + if (pMapping == nullptr) { + return nullptr; + } // Controller cannot take ownership if pMapping is referenced elsewhere because // the controller polling thread needs exclusive accesses to the non-thread safe // LegacyControllerMapping. diff --git a/src/controllers/controllermanager.cpp b/src/controllers/controllermanager.cpp index abfb47b40c9b..e5cba1c27c43 100644 --- a/src/controllers/controllermanager.cpp +++ b/src/controllers/controllermanager.cpp @@ -423,6 +423,7 @@ void ControllerManager::slotApplyMapping(Controller* pController, if (!pMapping) { closeController(pController); // Unset the controller mapping for this controller + pController->setMapping(nullptr); m_pConfig->remove(key); emit mappingApplied(false); return;