[server] Only send surface leave if resources are still valid

If a resource is null, because e.g. the surface got already destroyed,
wayland will create an error while marshalling arguments causing
the connected client to in worst case abort.
This commit is contained in:
Martin Gräßlin 2015-05-26 09:26:19 +02:00
parent ed080780fd
commit 35a854e991
2 changed files with 6 additions and 2 deletions

View file

@ -118,7 +118,9 @@ void KeyboardInterface::setFocusedSurface(SurfaceInterface *surface, quint32 ser
{ {
Q_D(); Q_D();
if (d->focusedSurface) { if (d->focusedSurface) {
wl_keyboard_send_leave(d->resource, serial, d->focusedSurface->resource()); if (d->resource && d->focusedSurface->resource()) {
wl_keyboard_send_leave(d->resource, serial, d->focusedSurface->resource());
}
disconnect(d->destroyConnection); disconnect(d->destroyConnection);
} }
d->focusedSurface = surface; d->focusedSurface = surface;

View file

@ -116,7 +116,9 @@ void PointerInterface::setFocusedSurface(SurfaceInterface *surface, quint32 seri
Q_D(); Q_D();
Q_ASSERT(d->resource); Q_ASSERT(d->resource);
if (d->focusedSurface) { if (d->focusedSurface) {
wl_pointer_send_leave(d->resource, serial, d->focusedSurface->resource()); if (d->resource && d->focusedSurface->resource()) {
wl_pointer_send_leave(d->resource, serial, d->focusedSurface->resource());
}
disconnect(d->destroyConnection); disconnect(d->destroyConnection);
} }
if (!surface) { if (!surface) {