From 3e53a6283d5509de0a3bede54e21ef5ea9da2b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 14 Jun 2015 00:52:55 +0200 Subject: [PATCH] [server] Add safety checks in SeatInterface::setFocusedFooSurface Check whether the resource for the Keyboard/Pointer/TouchInterface is still valid before trying to use it. This was hitting crashes in wayland during the wl_foo_send_enter calls. --- src/wayland/seat_interface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wayland/seat_interface.cpp b/src/wayland/seat_interface.cpp index d0f7855867..592d21e0a9 100644 --- a/src/wayland/seat_interface.cpp +++ b/src/wayland/seat_interface.cpp @@ -486,6 +486,9 @@ void SeatInterface::setFocusedPointerSurface(SurfaceInterface *surface, const QP d->globalPointer.focus = Private::Pointer::Focus(); d->globalPointer.focus.surface = surface; PointerInterface *p = d->pointerForSurface(surface); + if (!p->resource()) { + p = nullptr; + } d->globalPointer.focus.pointer = p; if (d->globalPointer.focus.surface) { d->globalPointer.focus.destroyConnection = connect(surface, &QObject::destroyed, this, @@ -664,6 +667,9 @@ void SeatInterface::setFocusedKeyboardSurface(SurfaceInterface *surface) d->keys.focus = Private::Keyboard::Focus(); d->keys.focus.surface = surface; KeyboardInterface *k = d->keyboardForSurface(surface); + if (!k->resource()) { + k = nullptr; + } d->keys.focus.keyboard = k; if (d->keys.focus.surface) { d->keys.focus.destroyConnection = connect(surface, &QObject::destroyed, this, @@ -825,6 +831,9 @@ void SeatInterface::setFocusedTouchSurface(SurfaceInterface *surface, const QPoi d->touchInterface.focus.surface = surface; d->touchInterface.focus.offset = surfacePosition; TouchInterface *t = d->touchForSurface(surface); + if (!t->resource()) { + t = nullptr; + } d->touchInterface.focus.touch = t; if (d->touchInterface.focus.surface) { d->touchInterface.focus.destroyConnection = connect(surface, &QObject::destroyed, this,