Commit 46cf9fc3 authored by Martin Flöser's avatar Martin Flöser
Browse files

[server] Add resource nullptr check to ShellSurfaceInterface

The ShellSurface might have the resource destroyed, before being deleted,
so there is a short time frame where resource might be null.

Crash was caught by KWin.

Reviewed-By: sebas and notmart
parent 5f5dbc51
......@@ -729,6 +729,11 @@ void TestWaylandShell::testDisconnect()
QVERIFY(clientDisconnectedSpy.wait());
QCOMPARE(clientDisconnectedSpy.count(), 1);
QCOMPARE(shellSurfaceDestroyedSpy.count(), 0);
// it's already unbound, but the shell surface is not yet destroyed
QVERIFY(!serverSurface->resource());
// ensure we don't crash when accessing it in this state
serverSurface->ping();
serverSurface->requestSize(QSize(1, 2));
QVERIFY(shellSurfaceDestroyedSpy.wait());
QCOMPARE(shellSurfaceDestroyedSpy.count(), 1);
......
......@@ -216,6 +216,9 @@ void ShellSurfaceInterface::Private::pong(quint32 serial)
void ShellSurfaceInterface::ping()
{
Q_D();
if (!d->resource) {
return;
}
d->ping();
}
......@@ -245,6 +248,9 @@ bool ShellSurfaceInterface::isPinged() const
void ShellSurfaceInterface::requestSize(const QSize &size)
{
Q_D();
if (!d->resource) {
return;
}
// TODO: what about the edges?
wl_shell_surface_send_configure(d->resource, 0, size.width(), size.height());
d->client->flush();
......
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