Commit 0523d4b2 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Add locking to KoJsonTraider

That fixes crashes in the multithreaded saving code
parent 17f0062d
......@@ -30,6 +30,7 @@
#include <QDir>
#include <QProcessEnvironment>
#include <QGlobalStatic>
#include <QMutexLocker>
KoJsonTrader::KoJsonTrader()
{
......@@ -110,6 +111,8 @@ KoJsonTrader* KoJsonTrader::instance()
QList<QPluginLoader *> KoJsonTrader::query(const QString &servicetype, const QString &mimetype) const
{
QMutexLocker l(&m_mutex);
QList<QPluginLoader *>list;
QDirIterator dirIter(m_pluginPath, QDirIterator::Subdirectories);
while (dirIter.hasNext()) {
......
......@@ -23,6 +23,7 @@
#include <QList>
#include <QString>
#include <QMutex>
#include "kritaplugin_export.h"
class QPluginLoader;
......@@ -68,6 +69,7 @@ public:
private:
QString m_pluginPath;
mutable QMutex m_mutex;
};
#endif
......@@ -155,8 +155,7 @@ QStringList KisImportExportManager::mimeFilter(Direction direction)
if (direction == KisImportExportManager::Import) {
if (m_importMimeTypes.isEmpty()) {
KoJsonTrader trader;
QList<QPluginLoader *>list = trader.query("Krita/FileFilter", "");
QList<QPluginLoader *>list = KoJsonTrader::instance()->query("Krita/FileFilter", "");
Q_FOREACH(QPluginLoader *loader, list) {
QJsonObject json = loader->metaData().value("MetaData").toObject();
Q_FOREACH(const QString &mimetype, json.value("X-KDE-Import").toString().split(",", QString::SkipEmptyParts)) {
......@@ -171,8 +170,7 @@ QStringList KisImportExportManager::mimeFilter(Direction direction)
}
else if (direction == KisImportExportManager::Export) {
if (m_exportMimeTypes.isEmpty()) {
KoJsonTrader trader;
QList<QPluginLoader *>list = trader.query("Krita/FileFilter", "");
QList<QPluginLoader *>list = KoJsonTrader::instance()->query("Krita/FileFilter", "");
Q_FOREACH(QPluginLoader *loader, list) {
QJsonObject json = loader->metaData().value("MetaData").toObject();
Q_FOREACH(const QString &mimetype, json.value("X-KDE-Export").toString().split(",", QString::SkipEmptyParts)) {
......@@ -338,10 +336,10 @@ KisImportExportManager::ConversionResult KisImportExportManager::convert(KisImpo
}
bool alsoAsKra = false;
if (!askUserAboutExportConfiguration(filter, exportConfiguration,
from, to,
batchMode(), showWarnings,
&alsoAsKra)) {
if (!batchMode() && !askUserAboutExportConfiguration(filter, exportConfiguration,
from, to,
batchMode(), showWarnings,
&alsoAsKra)) {
return KisImportExportFilter::UserCancelled;
}
......
......@@ -99,8 +99,7 @@ DlgAnimationRenderer::DlgAnimationRenderer(KisDocument *doc, QWidget *parent)
setMainWidget(m_page);
KoJsonTrader trader;
QList<QPluginLoader *>list = trader.query("Krita/AnimationExporter", "");
QList<QPluginLoader *>list = KoJsonTrader::instance()->query("Krita/AnimationExporter", "");
Q_FOREACH(QPluginLoader *loader, list) {
QJsonObject json = loader->metaData().value("MetaData").toObject();
QStringList mimetypes = json.value("X-KDE-Export").toString().split(",");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment