Commit 3e53a628 authored by Martin Flöser's avatar Martin Flöser
Browse files

[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.
parent fea4b92c
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment