Call destroyWindowManagementInterface from ShellClient::destroyClient

Summary:
So far destroyWindowManagementInterface was only called when the
ShellClient got unmapped. But it's possible (although not recommended)
to just destroy the Surface without prior unmapping. In that case the
PlasmaWindow got leaked.

This change addresses this problem by always calling
destroyWindowManagementInterface from ShellClient::destroyClient.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1762
This commit is contained in:
Martin Gräßlin 2016-06-03 16:53:23 +02:00
parent 210d57bb45
commit 0388ed02a6
2 changed files with 32 additions and 0 deletions

View file

@ -63,6 +63,7 @@ private Q_SLOTS:
void testInternalWindowNoPlasmaWindow();
void testPopupWindowNoPlasmaWindow();
void testLockScreenNoPlasmaWindow();
void testDestroyedButNotUnmapped();
private:
ConnectionThread *m_connection = nullptr;
@ -387,6 +388,36 @@ void PlasmaWindowTest::testLockScreenNoPlasmaWindow()
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<Surface> parentSurface(m_compositor->createSurface());
QScopedPointer<ShellSurface> 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<PlasmaWindow*>();
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)

View file

@ -184,6 +184,7 @@ void ShellClient::destroyClient()
del = Deleted::create(this);
}
emit windowClosed(this, del);
destroyWindowManagementInterface();
destroyDecoration();
if (workspace()) {