From bf932c4e9719ec9498f56a70099cbd62c0b955e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 14 Mar 2016 10:24:13 +0100 Subject: [PATCH] Fix crash when accessing ShellClient::iconGeometry for a not mapped window It uses windowManagementInterface which is null until the window is mapped. A not mapped window obviously has an invalid iconGeometry. --- autotests/wayland/start_test.cpp | 4 ++++ shell_client.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/autotests/wayland/start_test.cpp b/autotests/wayland/start_test.cpp index 395568cd75..0b1b4bcc36 100644 --- a/autotests/wayland/start_test.cpp +++ b/autotests/wayland/start_test.cpp @@ -127,6 +127,10 @@ void StartTest::testCreateWindow() // but still not yet in workspace QVERIFY(workspace()->allClientList().isEmpty()); + // icon geometry accesses windowManagementInterface which only exists after window became visible + // verify that accessing doesnt't crash + QVERIFY(waylandServer()->clients().first()->iconGeometry().isNull()); + // let's render QImage img(QSize(100, 50), QImage::Format_ARGB32); img.fill(Qt::blue); diff --git a/shell_client.cpp b/shell_client.cpp index 1986a4a4f6..2bf0ee2af4 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -473,6 +473,11 @@ bool ShellClient::isMinimizable() const QRect ShellClient::iconGeometry() const { + if (!windowManagementInterface()) { + // window management interface is only available if the surface is mapped + return QRect(); + } + int minDistance = INT_MAX; ShellClient *candidatePanel = nullptr; QRect candidateGeom;