From a3b4923c4218535878dcf68d27d8eca4ab3e0981 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 4 May 2024 00:48:25 +0100 Subject: [PATCH] input: ignore destroyed devices in static events fixes #5863 --- src/managers/input/InputManager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 10b12404..81ceae79 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -785,6 +785,10 @@ void CInputManager::setupKeyboard(SP keeb) { keeb->events.destroy.registerStaticListener( [this](void* owner, std::any data) { auto PKEEB = ((IKeyboard*)owner)->self.lock(); + + if (!PKEEB) + return; + destroyKeyboard(PKEEB); Debug::log(LOG, "Destroyed keyboard {:x}", (uintptr_t)owner); }, @@ -995,6 +999,10 @@ void CInputManager::setupMouse(SP mauz) { mauz->events.destroy.registerStaticListener( [this](void* mouse, std::any data) { const auto PMOUSE = (IPointer*)mouse; + + if (!PMOUSE) + return; + destroyPointer(PMOUSE->self.lock()); }, mauz.get()); @@ -1384,6 +1392,10 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) { PNEWDEV->events.destroy.registerStaticListener( [this](void* owner, std::any data) { auto PDEV = ((ITouch*)owner)->self.lock(); + + if (!PDEV) + return; + destroyTouchDevice(PDEV); }, PNEWDEV.get());