[client] Ensure PlasmaWindowModel removes deleted windows
Summary: There is a possibility that a PlasmaWindow is unmapped when the PlasmaWindowModel gets created. In this situation the unmapped PlasmaWindow will be deleted in the next event cycle. So far PlasmaWindowModel didn't handle this situation and the model might hold deleted objects due to this. This change addresses this potential problem and ensures the model gets updated when a PlasmaWindow is deleted. Test Plan: Test case which exposes the problem is added Reviewers: #plasma, hein Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D1622
This commit is contained in:
parent
2c5bc69d1d
commit
3fda8376b6
1 changed files with 34 additions and 0 deletions
|
@ -73,6 +73,7 @@ private Q_SLOTS:
|
||||||
void testRequests();
|
void testRequests();
|
||||||
// TODO: minimized geometry
|
// TODO: minimized geometry
|
||||||
// TODO: model reset
|
// TODO: model reset
|
||||||
|
void testCreateWithUnmappedWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool testBooleanData(PlasmaWindowModel::AdditionalRoles role, void (PlasmaWindowInterface::*function)(bool));
|
bool testBooleanData(PlasmaWindowModel::AdditionalRoles role, void (PlasmaWindowInterface::*function)(bool));
|
||||||
|
@ -681,5 +682,38 @@ void PlasmaWindowModelTest::testRequests()
|
||||||
QCOMPARE(shadeRequestedSpy.last().first().toBool(), false);
|
QCOMPARE(shadeRequestedSpy.last().first().toBool(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlasmaWindowModelTest::testCreateWithUnmappedWindow()
|
||||||
|
{
|
||||||
|
// this test verifies that creating the model just when an unmapped window exists doesn't cause problems
|
||||||
|
// that is the unmapped window should be added (as expected), but also be removed again
|
||||||
|
|
||||||
|
// create a window in "normal way"
|
||||||
|
QSignalSpy windowCreatedSpy(m_pw, &PlasmaWindowManagement::windowCreated);
|
||||||
|
QVERIFY(windowCreatedSpy.isValid());
|
||||||
|
auto w = m_pwInterface->createWindow(m_pwInterface);
|
||||||
|
QVERIFY(w);
|
||||||
|
QVERIFY(windowCreatedSpy.wait());
|
||||||
|
PlasmaWindow *window = windowCreatedSpy.first().first().value<PlasmaWindow*>();
|
||||||
|
QVERIFY(window);
|
||||||
|
QSignalSpy unmappedSpy(window, &PlasmaWindow::unmapped);
|
||||||
|
QVERIFY(unmappedSpy.isValid());
|
||||||
|
QSignalSpy destroyedSpy(window, &PlasmaWindow::destroyed);
|
||||||
|
QVERIFY(destroyedSpy.isValid());
|
||||||
|
// unmap should be triggered, but not yet the destroyed
|
||||||
|
w->unmap();
|
||||||
|
QVERIFY(unmappedSpy.wait());
|
||||||
|
QVERIFY(destroyedSpy.isEmpty());
|
||||||
|
|
||||||
|
auto model = m_pw->createWindowModel();
|
||||||
|
QVERIFY(model);
|
||||||
|
QCOMPARE(model->rowCount(), 1);
|
||||||
|
QSignalSpy rowRemovedSpy(model, &PlasmaWindowModel::rowsRemoved);
|
||||||
|
QVERIFY(rowRemovedSpy.isValid());
|
||||||
|
QVERIFY(rowRemovedSpy.wait());
|
||||||
|
QCOMPARE(rowRemovedSpy.count(), 1);
|
||||||
|
QCOMPARE(model->rowCount(), 0);
|
||||||
|
QCOMPARE(destroyedSpy.count(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(PlasmaWindowModelTest)
|
QTEST_GUILESS_MAIN(PlasmaWindowModelTest)
|
||||||
#include "test_plasma_window_model.moc"
|
#include "test_plasma_window_model.moc"
|
||||||
|
|
Loading…
Reference in a new issue