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
This commit is contained in:
Marco Martin 2014-09-13 13:55:32 +02:00
parent 0b0daa2318
commit 052a0c32ae
4 changed files with 49 additions and 4 deletions

View File

@ -31,6 +31,8 @@ Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint apple
return new SimpleApplet(0, QString(), appletId); return new SimpleApplet(0, QString(), appletId);
} else if (name == "simplecontainment") { } else if (name == "simplecontainment") {
return new SimpleContainment(0, QString(), appletId); return new SimpleContainment(0, QString(), appletId);
} else if (name == "simplenoscreencontainment") {
return new SimpleNoScreenContainment(0, QString(), appletId);
} else { } else {
return 0; return 0;
} }
@ -52,6 +54,14 @@ QRect SimpleCorona::screenGeometry(int screen) const
return QRect(100*screen, 100, 100, 100); return QRect(100*screen, 100, 100, 100);
} }
int SimpleCorona::screenForContainment(const Plasma::Containment *c) const
{
if (qobject_cast<const SimpleNoScreenContainment *>(c)) {
return -1;
}
return 0;
}
SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId) SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId)
: Plasma::Applet(parent, serviceId, 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() static void runKBuildSycoca()
{ {
@ -129,8 +143,20 @@ void CoronaTest::cleanupTestCase()
void CoronaTest::restore() void CoronaTest::restore()
{ {
m_corona->loadLayout("plasma-test-appletsrc"); m_corona->loadLayout("plasma-test-appletsrc");
QCOMPARE(m_corona->containments().count(), 2); QCOMPARE(m_corona->containments().count(), 3);
QCOMPARE(m_corona->containments().first()->applets().count(), 2); //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() void CoronaTest::startupCompletion()

View File

@ -43,6 +43,7 @@ public:
~SimpleCorona(); ~SimpleCorona();
QRect screenGeometry(int) const; QRect screenGeometry(int) const;
int screenForContainment(const Plasma::Containment *) const;
}; };
class SimpleApplet : public Plasma::Applet class SimpleApplet : public Plasma::Applet
@ -65,6 +66,14 @@ private:
QTimer m_timer; 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 class CoronaTest : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -22,5 +22,15 @@ lastScreen=0
location=4 location=4
plugin=simplecontainment 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] [General]
immutability=1 immutability=1

View File

@ -557,7 +557,7 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
if (!mergeConfig) { if (!mergeConfig) {
containmentsStarting = 0; containmentsStarting = 0;
foreach (Containment *containment, containments) { foreach (Containment *containment, containments) {
if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) { if (!containment->isUiReady() && containment->screen() < q->numScreens() && containment->screen() >= 0) {
++containmentsStarting; ++containmentsStarting;
QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](bool ready) { QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](bool ready) {
if (!ready) { if (!ready) {