Skip to content

Commit 427690a

Browse files
authored
Merge pull request #153 from horriblename/fix/segfault
fix: segfault
2 parents d0033c9 + 676e6df commit 427690a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/GestureManager.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void GestureManager::sendCancelEventsToWindows() {
272272

273273
for (const auto& touch : this->touchedResources.all()) {
274274
const auto t = touch.lock();
275-
if (t.impl_) { // FIXME: idk how to check weak pointer validity
275+
if (t.get()) {
276276
t->sendCancel();
277277
}
278278
}
@@ -366,16 +366,23 @@ bool GestureManager::onTouchUp(ITouch::SUpEvent ev) {
366366
if (**SEND_CANCEL) {
367367
const auto surface = g_pInputManager->m_sTouchData.touchFocusSurface;
368368

369+
if (!surface.valid()) {
370+
return true;
371+
}
372+
369373
wl_client* client = surface.get()->client();
370-
if (client) {
371-
SP<CWLSeatResource> seat = g_pSeatManager->seatResourceForClient(client);
374+
if (!client) {
375+
return true;
376+
}
372377

373-
if (seat) {
374-
auto touches = seat.get()->touches;
375-
for (const auto& touch : touches) {
376-
this->touchedResources.remove(touch);
377-
}
378-
}
378+
SP<CWLSeatResource> seat = g_pSeatManager->seatResourceForClient(client);
379+
if (!seat.get()) {
380+
return true;
381+
}
382+
383+
auto touches = seat.get()->touches;
384+
for (const auto& touch : touches) {
385+
this->touchedResources.remove(touch);
379386
}
380387

381388
return BLOCK;

0 commit comments

Comments
 (0)