From f4770e0e87af464e2b6b55a22d1189e84a0f103c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:09:18 +0200 Subject: [PATCH 1/2] fix: segfault --- src/GestureManager.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/GestureManager.cpp b/src/GestureManager.cpp index 7e8a848..58f960a 100644 --- a/src/GestureManager.cpp +++ b/src/GestureManager.cpp @@ -366,16 +366,23 @@ bool GestureManager::onTouchUp(ITouch::SUpEvent ev) { if (**SEND_CANCEL) { const auto surface = g_pInputManager->m_sTouchData.touchFocusSurface; + if (!surface.impl_) { + return true; + } + wl_client* client = surface.get()->client(); - if (client) { - SP seat = g_pSeatManager->seatResourceForClient(client); + if (!client) { + return true; + } - if (seat) { - auto touches = seat.get()->touches; - for (const auto& touch : touches) { - this->touchedResources.remove(touch); - } - } + SP seat = g_pSeatManager->seatResourceForClient(client); + if (!seat.impl_) { + return true; + } + + auto touches = seat.get()->touches; + for (const auto& touch : touches) { + this->touchedResources.remove(touch); } return BLOCK; From 676e6dfe168dd8106098d0aca63991e220dfb538 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:20:45 +0200 Subject: [PATCH 2/2] fix: use proper pointer checks --- src/GestureManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GestureManager.cpp b/src/GestureManager.cpp index 58f960a..e5bc91a 100644 --- a/src/GestureManager.cpp +++ b/src/GestureManager.cpp @@ -272,7 +272,7 @@ void GestureManager::sendCancelEventsToWindows() { for (const auto& touch : this->touchedResources.all()) { const auto t = touch.lock(); - if (t.impl_) { // FIXME: idk how to check weak pointer validity + if (t.get()) { t->sendCancel(); } } @@ -366,7 +366,7 @@ bool GestureManager::onTouchUp(ITouch::SUpEvent ev) { if (**SEND_CANCEL) { const auto surface = g_pInputManager->m_sTouchData.touchFocusSurface; - if (!surface.impl_) { + if (!surface.valid()) { return true; } @@ -376,7 +376,7 @@ bool GestureManager::onTouchUp(ITouch::SUpEvent ev) { } SP seat = g_pSeatManager->seatResourceForClient(client); - if (!seat.impl_) { + if (!seat.get()) { return true; }