Skip to content

Commit

Permalink
input: ignore destroyed devices in static events
Browse files Browse the repository at this point in the history
fixes #5863
  • Loading branch information
vaxerski committed May 3, 2024
1 parent 1237732 commit a3b4923
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ void CInputManager::setupKeyboard(SP<IKeyboard> 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);
},
Expand Down Expand Up @@ -995,6 +999,10 @@ void CInputManager::setupMouse(SP<IPointer> 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());
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit a3b4923

Please sign in to comment.