better delay of panel creation

it also avoids recursive checkLoadingDesktopsComplete that caused a crash
This commit is contained in:
Marco Martin 2013-10-22 14:55:46 +02:00
parent b9382aefb2
commit 82ef02217d
2 changed files with 21 additions and 5 deletions

View File

@ -34,6 +34,7 @@
#include <kactivities/controller.h> #include <kactivities/controller.h>
#include <kactivities/consumer.h> #include <kactivities/consumer.h>
#include "activity.h" #include "activity.h"
#include "desktopview.h" #include "desktopview.h"
#include "panelview.h" #include "panelview.h"
@ -54,6 +55,11 @@ public:
// constant controlling how long between requesting a configuration sync // constant controlling how long between requesting a configuration sync
// and one happening should occur. currently 10 seconds // and one happening should occur. currently 10 seconds
appConfigSyncTimer.setInterval(10000); appConfigSyncTimer.setInterval(10000);
waitingPanelsTimer = new QTimer(q);
waitingPanelsTimer->setSingleShot(true);
waitingPanelsTimer->setInterval(250);
connect(waitingPanelsTimer, &QTimer::timeout, q, &ShellCorona::createWaitingPanels);
} }
ShellCorona *q; ShellCorona *q;
@ -69,6 +75,7 @@ public:
QList<Plasma::Containment *> waitingPanels; QList<Plasma::Containment *> waitingPanels;
QSet<Plasma::Containment *> loadingDesktops; QSet<Plasma::Containment *> loadingDesktops;
QHash<QString, Activity*> activities; QHash<QString, Activity*> activities;
QTimer *waitingPanelsTimer;
QTimer appConfigSyncTimer; QTimer appConfigSyncTimer;
}; };
@ -389,13 +396,20 @@ void ShellCorona::checkLoadingDesktopsComplete()
} }
if (d->loadingDesktops.isEmpty()) { if (d->loadingDesktops.isEmpty()) {
d->waitingPanelsTimer->start();
} else {
d->waitingPanelsTimer->stop();
}
}
void ShellCorona::createWaitingPanels()
{
foreach (Plasma::Containment *cont, d->waitingPanels) { foreach (Plasma::Containment *cont, d->waitingPanels) {
d->panelViews[cont] = new PanelView(this); d->panelViews[cont] = new PanelView(this);
d->panelViews[cont]->setContainment(cont); d->panelViews[cont]->setContainment(cont);
} }
d->waitingPanels.clear(); d->waitingPanels.clear();
} }
}
void ShellCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment) void ShellCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment)
{ {
@ -413,6 +427,7 @@ void ShellCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Contain
d->panelViews[containment]->setContainment(0); d->panelViews[containment]->setContainment(0);
d->panelViews[containment]->deleteLater(); d->panelViews[containment]->deleteLater();
d->panelViews.remove(containment); d->panelViews.remove(containment);
d->waitingPanels.removeAll(containment);
} }
} }
checkLoadingDesktopsComplete(); checkLoadingDesktopsComplete();

View File

@ -125,6 +125,7 @@ protected Q_SLOTS:
private Q_SLOTS: private Q_SLOTS:
void checkLoadingDesktopsComplete(); void checkLoadingDesktopsComplete();
void createWaitingPanels();
void handleContainmentAdded(Plasma::Containment *c); void handleContainmentAdded(Plasma::Containment *c);
void showWidgetExplorer(); void showWidgetExplorer();
void toggleActivityManager(); void toggleActivityManager();