From 052a0c32ae554a3af068b9d89a0aed6a4d342125 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sat, 13 Sep 2014 13:55:32 +0200 Subject: [PATCH] base on screen() to see what containment is loading if a containment's lastScreen is not -1 (and a valid screen) *and* its activity() is not the current one, its QML will *not* be loaded, therefore it would dangle blocking corona::startupCompleted until the activity is selected Change-Id: I6757d29240a012377e9ff0a22fe16541ea712ee6 --- autotests/coronatest.cpp | 32 +++++++++++++++++++++++++++++--- autotests/coronatest.h | 9 +++++++++ autotests/plasma-test-appletsrc | 10 ++++++++++ src/plasma/corona.cpp | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/autotests/coronatest.cpp b/autotests/coronatest.cpp index 3967b8c9e..3e9b51bda 100644 --- a/autotests/coronatest.cpp +++ b/autotests/coronatest.cpp @@ -31,6 +31,8 @@ Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint apple return new SimpleApplet(0, QString(), appletId); } else if (name == "simplecontainment") { return new SimpleContainment(0, QString(), appletId); + } else if (name == "simplenoscreencontainment") { + return new SimpleNoScreenContainment(0, QString(), appletId); } else { return 0; } @@ -52,6 +54,14 @@ QRect SimpleCorona::screenGeometry(int screen) const return QRect(100*screen, 100, 100, 100); } +int SimpleCorona::screenForContainment(const Plasma::Containment *c) const +{ + if (qobject_cast(c)) { + return -1; + } + return 0; +} + SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId) : Plasma::Applet(parent, serviceId, appletId) { @@ -83,7 +93,11 @@ SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, }); } - +SimpleNoScreenContainment::SimpleNoScreenContainment(QObject *parent , const QString &serviceId, uint appletId) + : Plasma::Containment(parent, serviceId, appletId) +{ + //This containment will *never* be isUiReady() +} static void runKBuildSycoca() { @@ -129,8 +143,20 @@ void CoronaTest::cleanupTestCase() void CoronaTest::restore() { m_corona->loadLayout("plasma-test-appletsrc"); - QCOMPARE(m_corona->containments().count(), 2); - QCOMPARE(m_corona->containments().first()->applets().count(), 2); + 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: + QCOMPARE(cont->applets().count(), 2); + break; + default: + QCOMPARE(cont->applets().count(), 0); + break; + } + } } void CoronaTest::startupCompletion() diff --git a/autotests/coronatest.h b/autotests/coronatest.h index d4098ef3c..4f6d37f84 100644 --- a/autotests/coronatest.h +++ b/autotests/coronatest.h @@ -43,6 +43,7 @@ public: ~SimpleCorona(); QRect screenGeometry(int) const; + int screenForContainment(const Plasma::Containment *) const; }; class SimpleApplet : public Plasma::Applet @@ -65,6 +66,14 @@ private: QTimer m_timer; }; +class SimpleNoScreenContainment : public Plasma::Containment +{ + Q_OBJECT + +public: + explicit SimpleNoScreenContainment(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0); +}; + class CoronaTest : public QObject { Q_OBJECT diff --git a/autotests/plasma-test-appletsrc b/autotests/plasma-test-appletsrc index 972cd5997..a832e9a72 100644 --- a/autotests/plasma-test-appletsrc +++ b/autotests/plasma-test-appletsrc @@ -22,5 +22,15 @@ lastScreen=0 location=4 plugin=simplecontainment +#this is a desktop containment that even if has lastScreen=0 +#its screen will be -1: this is the case of a containment of +#another activity, not the current one +[Containments][5] +formfactor=0 +immutability=1 +lastScreen=0 +location=0 +plugin=simplenoscreencontainment + [General] immutability=1 diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index d51a9b8c7..81a327d73 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -557,7 +557,7 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con if (!mergeConfig) { containmentsStarting = 0; foreach (Containment *containment, containments) { - if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) { + if (!containment->isUiReady() && containment->screen() < q->numScreens() && containment->screen() >= 0) { ++containmentsStarting; QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](bool ready) { if (!ready) {