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 6993ecf9f7
commit edef5c1dc1
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);
} 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<const SimpleNoScreenContainment *>(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()

View File

@ -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

View File

@ -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

View File

@ -557,7 +557,7 @@ QList<Plasma::Containment *> 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) {