diff --git a/autotests/wayland/plasmawindow_test.cpp b/autotests/wayland/plasmawindow_test.cpp --- a/autotests/wayland/plasmawindow_test.cpp +++ b/autotests/wayland/plasmawindow_test.cpp @@ -63,6 +63,7 @@ void testInternalWindowNoPlasmaWindow(); void testPopupWindowNoPlasmaWindow(); void testLockScreenNoPlasmaWindow(); + void testDestroyedButNotUnmapped(); private: ConnectionThread *m_connection = nullptr; @@ -387,6 +388,36 @@ QVERIFY(!waylandServer()->isScreenLocked()); } +void PlasmaWindowTest::testDestroyedButNotUnmapped() +{ + // this test verifies that also when a ShellSurface gets destroyed without a prior unmap + // the PlasmaWindow gets destroyed on Client side + QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); + QVERIFY(plasmaWindowCreatedSpy.isValid()); + + // first create the parent window + QScopedPointer parentSurface(m_compositor->createSurface()); + QScopedPointer parentShellSurface(m_shell->createSurface(parentSurface.data())); + // map that window + QImage img(QSize(100, 50), QImage::Format_ARGB32); + img.fill(Qt::blue); + parentSurface->attachBuffer(m_shm->createBuffer(img)); + parentSurface->damage(QRect(0, 0, 100, 50)); + parentSurface->commit(); + // this should create a plasma window + QVERIFY(plasmaWindowCreatedSpy.wait()); + QCOMPARE(plasmaWindowCreatedSpy.count(), 1); + auto window = plasmaWindowCreatedSpy.first().first().value(); + QVERIFY(window); + QSignalSpy destroyedSpy(window, &QObject::destroyed); + QVERIFY(destroyedSpy.isValid()); + + // now destroy without an unmap + parentShellSurface.reset(); + parentSurface.reset(); + QVERIFY(destroyedSpy.wait()); +} + } WAYLANDTEST_MAIN(KWin::PlasmaWindowTest) diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -184,6 +184,7 @@ del = Deleted::create(this); } emit windowClosed(this, del); + destroyWindowManagementInterface(); destroyDecoration(); if (workspace()) {