From cb265d96fc5c9dc7f3cf0b9a5c6bb6237af8838b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 14 Sep 2012 16:08:45 +0200 Subject: [PATCH] Sync script loading, KConfGroup is not thread safe REVIEW: 106377 BUG: 305361 FIXED-IN: 4.9.2 --- scripting/scripting.cpp | 25 +++++++++++++++++++++---- scripting/scripting.h | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/scripting/scripting.cpp b/scripting/scripting.cpp index 8786bce8dc..69199779fb 100644 --- a/scripting/scripting.cpp +++ b/scripting/scripting.cpp @@ -470,17 +470,34 @@ KWin::Scripting::Scripting(QObject *parent) void KWin::Scripting::start() { +#if 0 + // TODO make this threaded again once KConfigGroup is sufficiently thread safe, bug #305361 and friends // perform querying for the services in a thread QFutureWatcher *watcher = new QFutureWatcher(this); connect(watcher, SIGNAL(finished()), this, SLOT(slotScriptsQueried())); + watcher->setFuture(QtConcurrent::run(this, &KWin::Scripting::queryScriptsToLoad, pluginStates, offers)); +#else + LoadScriptList scriptsToLoad = queryScriptsToLoad(); + for (LoadScriptList::const_iterator it = scriptsToLoad.constBegin(); + it != scriptsToLoad.constEnd(); + ++it) { + if (it->first) { + loadScript(it->second.first, it->second.second); + } else { + loadDeclarativeScript(it->second.first, it->second.second); + } + } + + runScripts(); +#endif +} + +LoadScriptList KWin::Scripting::queryScriptsToLoad() +{ KSharedConfig::Ptr _config = KGlobal::config(); QMap pluginStates = KConfigGroup(_config, "Plugins").entryMap(); KService::List offers = KServiceTypeTrader::self()->query("KWin/Script"); - watcher->setFuture(QtConcurrent::run(this, &KWin::Scripting::queryScriptsToLoad, pluginStates, offers)); -} -LoadScriptList KWin::Scripting::queryScriptsToLoad(QMap &pluginStates, KService::List &offers) -{ LoadScriptList scriptsToLoad; foreach (const KService::Ptr & service, offers) { diff --git a/scripting/scripting.h b/scripting/scripting.h index d48b3699b2..b70e4021db 100644 --- a/scripting/scripting.h +++ b/scripting/scripting.h @@ -214,7 +214,7 @@ private Q_SLOTS: void slotScriptsQueried(); private: - LoadScriptList queryScriptsToLoad(QMap &pluginStates, KService::List &); + LoadScriptList queryScriptsToLoad(); }; }