Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix broken unittests
Halla Rempt99a3a92aeb08
diff --git a/libs/flake/CMakeLists.txt b/libs/flake/CMakeLists.txtindex 44e0af96e8..03b1d80980 100644--- a/libs/flake/CMakeLists.txt+++ b/libs/flake/CMakeLists.txt@@ -6,6 +6,7 @@ include_directories(${CMAKE_SOURCE_DIR}/libs/flake/svg${CMAKE_SOURCE_DIR}/libs/flake/text${CMAKE_SOURCE_DIR}/libs/flake/xsimd+ ${CMAKE_SOURCE_DIR}/libs/flake/resources${CMAKE_BINARY_DIR}/libs/flake)@@ -268,6 +269,7 @@ target_include_directories(kritaflake$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools>$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/svg>$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/text>+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/resources>)set_target_properties(libraqm PROPERTIES POSITION_INDEPENDENT_CODE ON)diff --git a/libs/image/KisAslStorage.cpp b/libs/image/KisAslStorage.cppindex 9358aca2c9..6cf7f9661e 100644--- a/libs/image/KisAslStorage.cpp+++ b/libs/image/KisAslStorage.cpp@@ -15,7 +15,6 @@ KIS_DECLARE_STATIC_INITIALIZER {KisStoragePluginRegistry::instance()->addStoragePluginFactory(KisResourceStorage::StorageType::AdobeStyleLibrary, new KisStoragePluginFactory<KisAslStorage>());}-class AslTagIterator : public KisResourceStorage::TagIterator{public:diff --git a/libs/resources/KisResourceLocator.cpp b/libs/resources/KisResourceLocator.cppindex cbe8c2cf3a..7275c0e273 100644--- a/libs/resources/KisResourceLocator.cpp+++ b/libs/resources/KisResourceLocator.cpp@@ -1075,8 +1075,11 @@ void KisResourceLocator::findStorages()d->storages["memory"]->setMetaData(KisResourceStorage::s_meta_name, i18n("Temporary Resources"));// Add font storage- d->storages["fontregistery"] = QSharedPointer<KisResourceStorage>::create("fontregistery");- d->storages["fontregistery"]->setMetaData(KisResourceStorage::s_meta_name, i18n("Font Storage"));+ auto fontStorage = QSharedPointer<KisResourceStorage>::create("fontregistry");+ if (fontStorage && fontStorage->valid()) {+ d->storages["fontregistry"] = fontStorage;+ d->storages["fontregistry"]->setMetaData(KisResourceStorage::s_meta_name, i18n("Font Storage"));+ }// And add bundles and adobe librariesQStringList filters = QStringList() << "*.bundle" << "*.abr" << "*.asl";@@ -1129,7 +1132,7 @@ KisResourceStorageSP KisResourceLocator::memoryStorage() constKisResourceStorageSP KisResourceLocator::fontStorage() const{- return storageByLocation("fontregistery");+ return storageByLocation("fontregistry");}KisResourceLocator::ResourceStorage KisResourceLocator::getResourceStorage(int resourceId) constdiff --git a/libs/resources/KisResourceStorage.cpp b/libs/resources/KisResourceStorage.cppindex 2ee2101f65..0c72a3699f 100644--- a/libs/resources/KisResourceStorage.cpp+++ b/libs/resources/KisResourceStorage.cpp@@ -90,6 +90,7 @@ KisResourceStorage::KisResourceStorage(const QString &location){d->location = location;d->name = QFileInfo(d->location).fileName();+QFileInfo fi(d->location);if (fi.isDir()) {d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::Folder]->create(location));@@ -101,20 +102,33 @@ KisResourceStorage::KisResourceStorage(const QString &location)d->storageType = StorageType::Bundle;// XXX: should we also check whether there's a valid metadata entry? Or is this enough?d->valid = (fi.isReadable() && QuaZip(d->location).open(QuaZip::mdUnzip));- } else if (d->name.endsWith(".abr", Qt::CaseInsensitive)) {+ }+ else if (d->name.endsWith(".abr", Qt::CaseInsensitive)) {d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::AdobeBrushLibrary]->create(location));d->storageType = StorageType::AdobeBrushLibrary;d->valid = fi.isReadable();- } else if (d->name.endsWith(".asl", Qt::CaseInsensitive)) {+ }+ else if (d->name.endsWith(".asl", Qt::CaseInsensitive)) {d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::AdobeStyleLibrary]->create(location));d->storageType = StorageType::AdobeStyleLibrary;d->valid = d->storagePlugin->isValid();- } else if (d->location == "fontregistery") {- d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::FontStorage]->create(location));+ }++ else if (d->location == "fontregistry") {+ auto factory = KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::FontStorage];+ if (factory) {+ auto storage = factory->create(location);+ d->storagePlugin.reset(storage);+ d->valid = true;+ }+ else {+ d->valid = false;+ }d->name = location;d->storageType = StorageType::FontStorage;- d->valid = true;- } else if (d->location == "memory" || !QUuid::fromString(d->location).isNull() || (!d->location.isEmpty() && !fi.exists())) {++ }+ else if (d->location == "memory" || !QUuid::fromString(d->location).isNull() || (!d->location.isEmpty() && !fi.exists())) {d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::Memory]->create(location));d->name = location;d->storageType = StorageType::Memory;diff --git a/libs/resources/tests/TestResourceCacheDb.cpp b/libs/resources/tests/TestResourceCacheDb.cppindex b094b89d67..a7f357ca9a 100644--- a/libs/resources/tests/TestResourceCacheDb.cpp+++ b/libs/resources/tests/TestResourceCacheDb.cpp@@ -61,7 +61,7 @@ void TestResourceCacheDb::testLookupTables()QVERIFY(r);QVERIFY(query.lastError() == QSqlError());query.first();- QCOMPARE(query.value(0).toInt(), 6);+ QCOMPARE(query.value(0).toInt(), 7);r = query.exec("SELECT COUNT(*) FROM resource_types");QVERIFY(r);diff --git a/libs/ui/KisApplication.cpp b/libs/ui/KisApplication.cppindex 8b12830c59..a35327eaa6 100644--- a/libs/ui/KisApplication.cpp+++ b/libs/ui/KisApplication.cpp@@ -364,7 +364,7 @@ bool KisApplication::registerResources()i18nc("Resource type name", "Layer styles"),QStringList() << "application/x-photoshop-style"));- reg->add(new KisResourceLoader<KoFontFamily>(ResourceType::FontFamilies, ResourceType::FontFamilies, i18n("Font Families"), QStringList()));+ reg->add(new KisResourceLoader<KoFontFamily>(ResourceType::FontFamilies, ResourceType::FontFamilies, i18n("Font Families"), QStringList() << "application/x-font-ttf" << "application/x-font-otf"));reg->registerFixup(10, new KisBrushTypeMetaDataFixup());diff --git a/sdk/tests/kistest.h b/sdk/tests/kistest.hindex 167777dbda..1d7ecd4e07 100644--- a/sdk/tests/kistest.h+++ b/sdk/tests/kistest.h@@ -55,6 +55,7 @@# define QTEST_DISABLE_KEYPAD_NAVIGATION#endif+#if defined(TESTRESOURCES) || defined(TESTPIGMENT) || defined (TESTFLAKE) || defined(TESTBRUSH) || defined(TESTIMAGE) || defined(TESTUI)#include <QImageReader>#include <QList>@@ -74,19 +75,16 @@#include <KisResourceLocator.h>#include <KoResourcePaths.h>---#if defined(TESTRESOURCES) || defined(TESTPIGMENT) || defined (TESTFLAKE) || defined(TESTIMAGE) || defined(TESTBRUSH) || defined(TESTUI)#include <resources/KoSegmentGradient.h>#include <resources/KoStopGradient.h>#include <resources/KoColorSet.h>#include <resources/KoPattern.h>-#endif#if defined (TESTFLAKE) || defined(TESTIMAGE) || defined(TESTBRUSH) || defined(TESTUI)#if defined HAVE_SEEXPR#include <KisSeExprScript.h>#endif+#include <resources/KoFontFamily.h>#include <resources/KoGamutMask.h>#include <resources/KoSvgSymbolCollectionResource.h>#endif@@ -204,6 +202,7 @@ void registerResources()<< KisMimeDatabase::mimeTypeForSuffix("colors")<< KisMimeDatabase::mimeTypeForSuffix("xml")<< KisMimeDatabase::mimeTypeForSuffix("sbz")));+#endif#if defined (TESTFLAKE) || defined(TESTIMAGE) || defined(TESTBRUSH) || defined(TESTUI)@@ -212,6 +211,7 @@ void registerResources()#endifreg->add(new KisResourceLoader<KoGamutMask>(ResourceType::GamutMasks, ResourceType::GamutMasks, i18n("Gamut masks"), QStringList() << "application/x-krita-gamutmasks"));reg->add(new KisResourceLoader<KoSvgSymbolCollectionResource>(ResourceType::Symbols, ResourceType::Symbols, i18n("SVG symbol libraries"), QStringList() << "image/svg+xml"));+ reg->add(new KisResourceLoader<KoFontFamily>(ResourceType::FontFamilies, ResourceType::FontFamilies, i18n("Font Families"), QStringList() << "application/x-font-ttf" << "application/x-font-otf"));#endif