Ensure corona::containments() is ordered
the order in which containments were restored used to be quite random: ensure that's ordered by id this makes the shell startups be more reproduceable from one to another, if a new containment arrives, ensure it's inserted maintaining id order containment::appelts() will need the same treatment adds a test as well that checks the order is right Change-Id: Ie1b278e5b83d7e3645f7293bf6d030aa7f43a221
This commit is contained in:
parent
052a0c32ae
commit
a159208d54
@ -144,9 +144,7 @@ void CoronaTest::restore()
|
||||
{
|
||||
m_corona->loadLayout("plasma-test-appletsrc");
|
||||
QCOMPARE(m_corona->containments().count(), 3);
|
||||
//TODO: check the order of m_corona->containments() is stable:
|
||||
//at the moment the ordering seems pretty random
|
||||
//same thing for the order of containment->applets()
|
||||
|
||||
for (auto cont : m_corona->containments()) {
|
||||
switch (cont->id()) {
|
||||
case 1:
|
||||
@ -157,6 +155,21 @@ void CoronaTest::restore()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CoronaTest::checkOrder()
|
||||
{
|
||||
QCOMPARE(m_corona->containments().count(), 3);
|
||||
|
||||
//check containments order
|
||||
QCOMPARE(m_corona->containments()[0]->id(), (uint)1);
|
||||
QCOMPARE(m_corona->containments()[1]->id(), (uint)4);
|
||||
QCOMPARE(m_corona->containments()[2]->id(), (uint)5);
|
||||
|
||||
//TODO: Containment::applets() order check
|
||||
}
|
||||
|
||||
void CoronaTest::startupCompletion()
|
||||
|
@ -84,6 +84,7 @@ public Q_SLOTS:
|
||||
|
||||
private Q_SLOTS:
|
||||
void restore();
|
||||
void checkOrder();
|
||||
void startupCompletion();
|
||||
void addRemoveApplets();
|
||||
void immutability();
|
||||
|
@ -477,7 +477,11 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
|
||||
conf.deleteGroup();
|
||||
}
|
||||
|
||||
containments.append(containment);
|
||||
//make sure the containments are sorted by id
|
||||
auto position = std::lower_bound(containments.begin(), containments.end(), containment, [](Plasma::Containment *c1, Plasma::Containment *c2) {
|
||||
return c1->id() < c2->id();
|
||||
});
|
||||
containments.insert(position, containment);
|
||||
|
||||
QObject::connect(containment, SIGNAL(destroyed(QObject*)),
|
||||
q, SLOT(containmentDestroyed(QObject*)));
|
||||
@ -514,8 +518,10 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
|
||||
}
|
||||
|
||||
KConfigGroup containmentsGroup(&conf, "Containments");
|
||||
QStringList groups = containmentsGroup.groupList();
|
||||
qSort(groups.begin(), groups.end());
|
||||
|
||||
foreach (const QString &group, containmentsGroup.groupList()) {
|
||||
foreach (const QString &group, groups) {
|
||||
KConfigGroup containmentConfig(&containmentsGroup, group);
|
||||
|
||||
if (containmentConfig.entryMap().isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user