move KServiceTypeTrader::query() to main thread

KConfigGroup is not the least thread safe and unfortunately
the KServiceTypeTrader::self()->query() will in doubt create
one if the sycoca database was damaged.

BUG: 303713
REVIEW: 105608
icc-effect-5.14.5
Thomas Lübking 2012-07-20 22:01:26 +02:00
parent ff1ba460ec
commit 6a934502b8
2 changed files with 5 additions and 4 deletions

View File

@ -475,12 +475,12 @@ void KWin::Scripting::start()
connect(watcher, SIGNAL(finished()), this, SLOT(slotScriptsQueried()));
KSharedConfig::Ptr _config = KGlobal::config();
QMap<QString,QString> pluginStates = KConfigGroup(_config, "Plugins").entryMap();
watcher->setFuture(QtConcurrent::run(this, &KWin::Scripting::queryScriptsToLoad, pluginStates));
KService::List offers = KServiceTypeTrader::self()->query("KWin/Script");
watcher->setFuture(QtConcurrent::run(this, &KWin::Scripting::queryScriptsToLoad, pluginStates, offers));
}
LoadScriptList KWin::Scripting::queryScriptsToLoad(QMap<QString,QString> &pluginStates)
LoadScriptList KWin::Scripting::queryScriptsToLoad(QMap<QString,QString> &pluginStates, KService::List &offers)
{
KService::List offers = KServiceTypeTrader::self()->query("KWin/Script");
LoadScriptList scriptsToLoad;
foreach (const KService::Ptr & service, offers) {

View File

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_SCRIPTING_H
#include <kwinglobals.h>
#include <kservice.h>
#include <QtCore/QFile>
#include <QtCore/QHash>
@ -213,7 +214,7 @@ private Q_SLOTS:
void slotScriptsQueried();
private:
LoadScriptList queryScriptsToLoad(QMap<QString,QString> &pluginStates);
LoadScriptList queryScriptsToLoad(QMap<QString,QString> &pluginStates, KService::List &);
};
}