Commit 8aab5a89 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Use a set for the resource folders.

parent 956d6cdb
......@@ -20,6 +20,7 @@
#include "KisResourceLoaderRegistry.h"
#include <QApplication>
#include <QString>
KisResourceLoaderRegistry::KisResourceLoaderRegistry(QObject *parent)
: QObject(parent)
......@@ -40,11 +41,11 @@ KisResourceLoaderRegistry* KisResourceLoaderRegistry::instance()
return reg;
}
QStringList KisResourceLoaderRegistry::resourceFolders() const
QSet<QString> KisResourceLoaderRegistry::resourceFolders() const
{
QStringList r;
Q_FOREACH(KisResourceLoaderBase *loader, values()) {
r << loader->folder();
}
return r;
return QSet<QString>::fromList(r);
}
......@@ -20,8 +20,10 @@
#ifndef KISRESOURCELOADERREGISTRY_H
#define KISRESOURCELOADERREGISTRY_H
#include <KoGenericRegistry.h>
#include <QObject>
#include <QSet>
#include <KoGenericRegistry.h>
#include "KisResourceLoader.h"
#include <kritaresources_export.h>
......@@ -34,7 +36,7 @@ public:
static KisResourceLoaderRegistry *instance();
QStringList resourceFolders() const;
QSet<QString> resourceFolders() const;
private:
......
......@@ -146,9 +146,10 @@ KisResourceLocator::LocatorError KisResourceLocator::firstTimeInstallation(Inita
if (dir.exists()) {
Q_FOREACH(const QString &entry, dir.entryList(QDir::Files | QDir::Readable)) {
QFile f(dir.canonicalPath() + '/'+ entry);
bool r = f.copy(d->resourceLocation + '/' + folder + '/' + entry);
if (!r) {
d->errorMessages << i18n("Could not copy resource %1 to the resource folder").arg(f.fileName());
if (!QFileInfo(d->resourceLocation + '/' + folder + '/' + entry).exists()) {
if (!f.copy(d->resourceLocation + '/' + folder + '/' + entry)) {
d->errorMessages << i18n("Could not copy resource %1 to %2").arg(f.fileName()).arg(d->resourceLocation + '/' + folder + '/' + entry);
}
}
}
}
......
......@@ -312,7 +312,7 @@ void KisApplication::addResourceTypes()
KoResourcePaths::setReady();
}
void KisApplication::loadResources()
bool KisApplication::loadResources()
{
KisResourceLoaderRegistry *reg = KisResourceLoaderRegistry::instance();
......@@ -352,18 +352,18 @@ void KisApplication::loadResources()
KisResourceLocator::LocatorError r = KisResourceLocator::instance()->initialize(KoResourcePaths::getApplicationRoot() + "/share/krita");
if (r != KisResourceLocator::LocatorError::Ok ) {
QMessageBox::critical(0, i18nc("@title:window", "Krita: Fatal error"), KisResourceLocator::instance()->errorMessages().join('\n') + i18n("Krita will quit now."));
qApp->quit();
QMessageBox::critical(0, i18nc("@title:window", "Krita: Fatal error"), KisResourceLocator::instance()->errorMessages().join('\n') + i18n("\n\nKrita will quit now."));
return false;
}
if (!KisResourceCacheDb::initialize(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QMessageBox::critical(0, i18nc("@title:window", "Krita: Fatal error"), i18n("Could not create the resources cache database. Krita will quit now."));
qApp->quit();
return false;
}
if (!KisResourceLocator::instance()->synchronizeDb()) {
QMessageBox::critical(0, i18nc("@title:window", "Krita: Fatal error"), KisResourceLocator::instance()->errorMessages().join('\n') + i18n("Krita will quit now."));
qApp->quit();
QMessageBox::critical(0, i18nc("@title:window", "Krita: Fatal error"), KisResourceLocator::instance()->errorMessages().join('\n') + i18n("\n\nKrita will quit now."));
return false;
}
......@@ -383,7 +383,7 @@ void KisApplication::loadResources()
processEvents();
KisResourceBundleServerProvider::instance();
return true;
}
void KisApplication::loadResourceTags()
......@@ -508,7 +508,9 @@ bool KisApplication::start(const KisApplicationArguments &args)
loadPlugins();
// Load all resources
loadResources();
if (!loadResources()) {
return false;
}
// Load all the tags
loadResourceTags();
......
......@@ -97,7 +97,7 @@ public:
bool notify(QObject *receiver, QEvent *event) override;
void addResourceTypes();
void loadResources();
bool loadResources();
void loadResourceTags();
void loadPlugins();
void loadGuiPlugins();
......
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