diff --git a/containment.cpp b/containment.cpp index 330b54281..15c025474 100644 --- a/containment.cpp +++ b/containment.cpp @@ -988,7 +988,9 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn //kDebug() << activity() << "setting screen to " << newScreen << newDesktop << "and type is" << type; Containment *swapScreensWith(0); - if (type == Containment::DesktopContainment || type >= Containment::CustomContainment) { + const bool isDesktopContainment = type == Containment::DesktopContainment || + type == Containment::CustomContainment; + if (isDesktopContainment) { // we want to listen to changes in work area if our screen changes if (toolBox) { if (screen < 0 && newScreen > -1) { @@ -1014,8 +1016,7 @@ void ContainmentPrivate::setScreen(int newScreen, int newDesktop, bool preventIn } } - if (newScreen < numScreens && newScreen > -1 && - (type == Containment::DesktopContainment || type >= Containment::CustomContainment)) { + if (newScreen < numScreens && newScreen > -1 && isDesktopContainment) { q->resize(corona->screenGeometry(newScreen).size()); } diff --git a/private/containment_p.h b/private/containment_p.h index dacedad57..00d96bed9 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -65,10 +65,14 @@ public: ~ContainmentPrivate() { - qDeleteAll(applets); + // qDeleteAll is broken with Qt4.8, delete it by hand + while (!applets.isEmpty()) { + delete applets.first(); + } applets.clear(); qDeleteAll(dropMenus); + dropMenus.clear(); } void createToolBox(); diff --git a/private/runnerjobs.cpp b/private/runnerjobs.cpp index 67bb501fe..6a8a7710f 100644 --- a/private/runnerjobs.cpp +++ b/private/runnerjobs.cpp @@ -170,10 +170,11 @@ Plasma::AbstractRunner* FindMatchesJob::runner() const return m_runner; } -DelayedJobCleaner::DelayedJobCleaner(QSet jobs, ThreadWeaver::WeaverInterface *weaver) - : QObject(weaver), - m_weaver(weaver), - m_jobs(jobs) +DelayedJobCleaner::DelayedJobCleaner(const QSet &jobs, const QSet &runners) + : QObject(Weaver::instance()), + m_weaver(Weaver::instance()), + m_jobs(jobs), + m_runners(runners) { connect(m_weaver, SIGNAL(finished()), this, SLOT(checkIfFinished())); @@ -182,6 +183,11 @@ DelayedJobCleaner::DelayedJobCleaner(QSet jobs, ThreadWeaver::W } } +DelayedJobCleaner::~DelayedJobCleaner() +{ + qDeleteAll(m_runners); +} + void DelayedJobCleaner::jobDone(ThreadWeaver::Job *job) { FindMatchesJob *runJob = dynamic_cast(job); diff --git a/private/runnerjobs_p.h b/private/runnerjobs_p.h index 19c0f1efa..0f400983e 100644 --- a/private/runnerjobs_p.h +++ b/private/runnerjobs_p.h @@ -126,16 +126,17 @@ private: class DelayedJobCleaner : public QObject { public: - DelayedJobCleaner(QSet jobs, ThreadWeaver::WeaverInterface *weaver); + DelayedJobCleaner(const QSet &jobs, const QSet &runners = QSet()); + ~DelayedJobCleaner(); private Q_SLOTS: void jobDone(ThreadWeaver::Job*); void checkIfFinished(); - //connect(ThreadWeaver::instance(), SIGNAL(finished()), this, SLOT(checkIfFinished())); private: ThreadWeaver::WeaverInterface *m_weaver; QSet m_jobs; + QSet m_runners; }; } diff --git a/runnermanager.cpp b/runnermanager.cpp index 7eba834f1..2021f7443 100644 --- a/runnermanager.cpp +++ b/runnermanager.cpp @@ -177,7 +177,7 @@ public: KPluginInfo::List offers = RunnerManager::listRunnerInfo(); const bool loadAll = config.readEntry("loadAll", false); - QStringList whiteList = config.readEntry("pluginWhiteList", QStringList()); + const QStringList whiteList = config.readEntry("pluginWhiteList", QStringList()); const bool noWhiteList = whiteList.isEmpty(); KConfigGroup pluginConf; if (conf.isValid()) { @@ -188,6 +188,7 @@ public: advertiseSingleRunnerIds.clear(); + QSet deadRunners; QMutableListIterator it(offers); while (it.hasNext()) { KPluginInfo &description = it.next(); @@ -203,8 +204,7 @@ public: description.load(pluginConf); const bool loaded = runners.contains(runnerName); - const bool selected = loadAll || - (description.isPluginEnabled() && (noWhiteList || whiteList.contains(runnerName))); + const bool selected = loadAll || (description.isPluginEnabled() && (noWhiteList || whiteList.contains(runnerName))); const bool singleQueryModeEnabled = description.property("X-Plasma-AdvertiseSingleRunnerQueryMode").toBool(); @@ -223,11 +223,35 @@ public: } } else if (loaded) { //Remove runner - AbstractRunner *runner = runners.take(runnerName); + deadRunners.insert(runners.take(runnerName)); #ifndef NDEBUG kDebug() << "Removing runner: " << runnerName; #endif - delete runner; + } + } + + if (!deadRunners.isEmpty()) { + QSet deadJobs; + foreach (FindMatchesJob *job, searchJobs) { + if (deadRunners.contains(job->runner())) { + QObject::disconnect(job, SIGNAL(done(ThreadWeaver::Job*)), q, SLOT(jobDone(ThreadWeaver::Job*))); + searchJobs.remove(job); + deadJobs.insert(job); + } + } + + foreach (FindMatchesJob *job, oldSearchJobs) { + if (deadRunners.contains(job->runner())) { + oldSearchJobs.remove(job); + deadJobs.insert(job); + } + } + + if (deadJobs.isEmpty()) { + qDeleteAll(deadRunners); + } else { + new DelayedJobCleaner(deadJobs, deadRunners); +>>>>>>> origin/KDE/4.7 } } @@ -437,7 +461,7 @@ RunnerManager::RunnerManager(KConfigGroup &c, QObject *parent) RunnerManager::~RunnerManager() { if (!qApp->closingDown() && (!d->searchJobs.isEmpty() || !d->oldSearchJobs.isEmpty())) { - new DelayedJobCleaner(d->searchJobs + d->oldSearchJobs, Weaver::instance()); + new DelayedJobCleaner(d->searchJobs + d->oldSearchJobs); } delete d; @@ -451,11 +475,13 @@ void RunnerManager::reloadConfiguration() void RunnerManager::setAllowedRunners(const QStringList &runners) { - qDeleteAll(d->runners); - d->runners.clear(); - KConfigGroup config = d->configGroup(); config.writeEntry("pluginWhiteList", runners); + + if (!d->runners.isEmpty()) { + // this has been called with runners already created. so let's do an instant reload + d->loadRunners(); + } } QStringList RunnerManager::allowedRunners() const