Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Rewrite KoPluginLoader::load()

Dmitry Kazakov568d7239fc25
diff --git a/libs/flake/KoDockRegistry.cpp b/libs/flake/KoDockRegistry.cpp
index 4584fa34f4..ae9c8a47b3 100644
--- a/libs/flake/KoDockRegistry.cpp
+++ b/libs/flake/KoDockRegistry.cpp
@@ -25,7 +25,6 @@ KoDockRegistry::KoDockRegistry()
void KoDockRegistry::init()
{
KoPluginLoader::PluginsConfig config;
- config.whiteList = "DockerPlugins";
config.blacklist = "DockerPluginsDisabled";
config.group = "krita";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/Dock"),
diff --git a/libs/flake/KoFilterEffectRegistry.cpp b/libs/flake/KoFilterEffectRegistry.cpp
index c67b089a09..18bdbb4352 100644
--- a/libs/flake/KoFilterEffectRegistry.cpp
+++ b/libs/flake/KoFilterEffectRegistry.cpp
@@ -24,7 +24,7 @@ KoFilterEffectRegistry::KoFilterEffectRegistry()
void KoFilterEffectRegistry::init()
{
KoPluginLoader::PluginsConfig config;
- config.whiteList = "FilterEffectPlugins";
+ config.group = "krita";
config.blacklist = "FilterEffectPluginsDisabled";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/FilterEffect"),
config);
diff --git a/libs/flake/KoShapeRegistry.cpp b/libs/flake/KoShapeRegistry.cpp
index cac1092b64..0e0d961b44 100644
--- a/libs/flake/KoShapeRegistry.cpp
+++ b/libs/flake/KoShapeRegistry.cpp
@@ -56,12 +56,10 @@ KoShapeRegistry::~KoShapeRegistry()
void KoShapeRegistry::Private::init(KoShapeRegistry *q)
{
KoPluginLoader::PluginsConfig config;
- config.whiteList = "FlakePlugins";
config.blacklist = "FlakePluginsDisabled";
config.group = "krita";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/Flake"),
config);
- config.whiteList = "ShapePlugins";
config.blacklist = "ShapePluginsDisabled";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/Shape"),
config);
diff --git a/libs/flake/KoToolRegistry.cpp b/libs/flake/KoToolRegistry.cpp
index 17249b078b..b73ac7cf96 100644
--- a/libs/flake/KoToolRegistry.cpp
+++ b/libs/flake/KoToolRegistry.cpp
@@ -30,7 +30,6 @@ void KoToolRegistry::init()
{
KoPluginLoader::PluginsConfig config;
config.group = "krita";
- config.whiteList = "ToolPlugins";
config.blacklist = "ToolPluginsDisabled";
KoPluginLoader::instance()->load(QString::fromLatin1("Krita/Tool"),
config);
diff --git a/libs/flake/Mainpage.dox b/libs/flake/Mainpage.dox
index 2927ad62b4..c05198cbb0 100644
--- a/libs/flake/Mainpage.dox
+++ b/libs/flake/Mainpage.dox
@@ -63,8 +63,7 @@ ServiceTypes=Krita/Shape
Type=Service
X-KDE-PluginInfo-Name=myflakeshapes
X-KDE-Library=myflakeshapesplugin
-X-Flake-MinVersion=27
-X-Flake-PluginVersion=27
+X-Krita-Version=27
@endverbatim
*
*/
diff --git a/libs/koplugin/CMakeLists.txt b/libs/koplugin/CMakeLists.txt
index 73d03ee4a1..c3c6368b20 100644
--- a/libs/koplugin/CMakeLists.txt
+++ b/libs/koplugin/CMakeLists.txt
@@ -28,3 +28,4 @@ set_target_properties(kritaplugin PROPERTIES
)
install(TARGETS kritaplugin ${INSTALL_TARGETS_DEFAULT_ARGS} )
+add_subdirectory(tests)
\ No newline at end of file
diff --git a/libs/koplugin/KoPluginLoader.cpp b/libs/koplugin/KoPluginLoader.cpp
index dd86a96ca1..61f4d40fa1 100644
--- a/libs/koplugin/KoPluginLoader.cpp
+++ b/libs/koplugin/KoPluginLoader.cpp
@@ -21,6 +21,42 @@
#include <KConfigGroup>
#include <KPluginFactory>
+namespace
+{
+int versionFromPlugin(const KoJsonTrader::Plugin &plugin)
+{
+ QJsonObject json = plugin.metaData().value("MetaData").toObject();
+ QVariant version = json.value("X-Krita-Version");
+ return version.toString().toInt();
+};
+
+QString idFromPlugin(const KoJsonTrader::Plugin &plugin)
+{
+ QJsonObject json = plugin.metaData().value("MetaData").toObject();
+ return json.value("Id").toString();
+};
+
+bool versionCompareLess(const KoJsonTrader::Plugin &lhs, const KoJsonTrader::Plugin &rhs)
+{
+ return versionFromPlugin(lhs) < versionFromPlugin(rhs);
+};
+
+bool idCompareEqual(const KoJsonTrader::Plugin &lhs, const KoJsonTrader::Plugin &rhs)
+{
+ return idFromPlugin(lhs) == idFromPlugin(rhs);
+};
+
+bool sortByIdAndReversedVersion(const KoJsonTrader::Plugin &lhs, const KoJsonTrader::Plugin &rhs)
+{
+ const QString lhsId = idFromPlugin(lhs);
+ const QString rhsId = idFromPlugin(lhs);
+ return lhsId < rhsId ||
+ (lhsId == rhsId && versionCompareLess(rhs, lhs));
+};
+
+} // namespace
+
+
class Q_DECL_HIDDEN KoPluginLoader::Private
{
public:
@@ -46,99 +82,71 @@ KoPluginLoader* KoPluginLoader::instance()
void KoPluginLoader::load(const QString & serviceType, const PluginsConfig &config, QObject* owner, bool cache)
{
-
// Don't load the same plugins again
if (cache && d->loadedServiceTypes.contains(serviceType)) {
return;
}
d->loadedServiceTypes << serviceType;
- QList<KoJsonTrader::Plugin> offers = KoJsonTrader::instance()->query(serviceType, QString());
-
- QList<KoJsonTrader::Plugin> plugins;
-
- bool configChanged = false;
- QList<QString> blacklist; // what we will save out afterwards
- if (config.whiteList && config.blacklist && config.group) {
- dbgPlugins << "Loading" << serviceType << "with checking the config";
- KConfigGroup configGroup(KSharedConfig::openConfig(), config.group);
- QList<QString> whiteList = configGroup.readEntry(config.whiteList, config.defaults);
- QList<QString> knownList;
-
- // if there was no list of defaults; all plugins are loaded.
- const bool firstStart = !config.defaults.isEmpty() && !configGroup.hasKey(config.whiteList);
- knownList = configGroup.readEntry(config.blacklist, knownList);
- if (firstStart) {
- configChanged = true;
- }
- Q_FOREACH (const KoJsonTrader::Plugin &loader, offers) {
- QJsonObject json = loader.metaData().value("MetaData").toObject();
- const QString pluginName = json.value("Id").toString();
- if (pluginName.isEmpty()) {
- qWarning() << "Loading plugin" << loader.fileName() << "failed, has no X-KDE-PluginInfo-Name.";
- continue;
- }
-
- if (whiteList.contains(pluginName)) {
- plugins.append(loader);
- }
- else if (!firstStart && !knownList.contains(pluginName)) { // also load newly installed plugins.
- plugins.append(loader);
- configChanged = true;
- }
- else {
- blacklist << pluginName;
- }
+ QList<KoJsonTrader::Plugin> plugins = KoJsonTrader::instance()->query(serviceType, QString());
+
+ {
+ /**
+ * First, remove all the duplicated plugins and keep only the ones with
+ * the highest version number
+ */
+ std::sort(plugins.begin(), plugins.end(), &sortByIdAndReversedVersion);
+ auto it = plugins.begin();
+ while ((it = std::adjacent_find(it, plugins.end(), &idCompareEqual)) != plugins.end()) {
+ warnPlugins << "Skipping duplicated plugin, id:" << idFromPlugin(*it)
+ << "version:" << versionFromPlugin(*it) << "filename:" << it->fileName();
+ plugins.erase(std::next(it));
}
- } else {
- plugins = offers;
}
- QMap<QString, KoJsonTrader::Plugin> serviceNames;
- Q_FOREACH (const KoJsonTrader::Plugin &loader, plugins) {
- if (serviceNames.contains(loader.fileName())) { // duplicate
- QJsonObject json2 = loader.metaData().value("MetaData").toObject();
- QVariant pluginVersion2 = json2.value("X-Flake-PluginVersion").toVariant();
- if (pluginVersion2.isNull()) { // just take the first one found...
- continue;
- }
- KoJsonTrader::Plugin currentLoader = serviceNames.value(loader.fileName());
- QJsonObject json = currentLoader.metaData().value("MetaData").toObject();
- QVariant pluginVersion = json.value("X-Flake-PluginVersion").toVariant();
- if (!(pluginVersion.isNull() || pluginVersion.toInt() < pluginVersion2.toInt())) {
- continue; // replace the old one with this one, since its newer.
+ if (config.isValid()) {
+ /**
+ * Then remove all the blacklisted plugins if necessary
+ */
+ KConfigGroup configGroup(KSharedConfig::openConfig(), config.group);
+ QStringList blackList = configGroup.readEntry(config.blacklist, QStringList());
+
+ auto it = plugins.begin();
+ while (it != plugins.end()) {
+ if (blackList.contains(idFromPlugin(*it))) {
+ it = plugins.erase(it);
+ } else {
+ ++it;
}
}
- serviceNames.insert(loader.fileName(), loader);
}
- QList<QString> whiteList;
- Q_FOREACH (const QString &serviceName, serviceNames.keys()) {
- dbgPlugins << "loading" << serviceName;
- KoJsonTrader::Plugin loader = serviceNames[serviceName];
- KPluginFactory *factory = qobject_cast<KPluginFactory *>(loader.instance());
- QObject *plugin = 0;
+ /**
+ * Now "load" all the plugins. If "owner" object is not provided, we just
+ * create the plugin object and immediately destroy it. Usually the constructor
+ * of this plugin will just populate some registry, so the object is not necessary
+ * anymore.
+ */
+ for (KoJsonTrader::Plugin &plugin : plugins) {
+ const QString pluginName = idFromPlugin(plugin);
+ dbgPlugins << "loading" << pluginName;
+
+ QObject *object = 0;
+
+ KPluginFactory *factory = qobject_cast<KPluginFactory *>(plugin.instance());
if (factory) {
- plugin = factory->create<QObject>(owner ? owner : this, QVariantList());
+ object = factory->create<QObject>(owner ? owner : this, QVariantList());
}
- if (plugin) {
- QJsonObject json = loader.metaData().value("MetaData").toObject();
- const QString pluginName = json.value("Id").toString();
- whiteList << pluginName;
- dbgPlugins << "\tLoaded plugin" << loader.fileName() << owner;
+
+ if (object) {
+ dbgPlugins << "\tLoaded plugin" << plugin.fileName() << "owner:" << owner;
if (!owner) {
- delete plugin;
+ delete object;
}
} else {
- qWarning() << "Loading plugin" << loader.fileName() << "failed, " << loader.errorString();
+ qWarning() << "\tLoading plugin" << plugin.fileName() << "failed, " << plugin.errorString();
}
}
-
- if (configChanged && config.whiteList && config.blacklist && config.group) {
- KConfigGroup configGroup(KSharedConfig::openConfig(), config.group);
- configGroup.writeEntry(config.whiteList, whiteList);
- configGroup.writeEntry(config.blacklist, blacklist);
- }
}
KPluginFactory* KoPluginLoader::loadSinglePlugin(const std::vector<std::pair<QString, QString>> &predicates, const QString &serviceType)
@@ -158,16 +166,6 @@ KPluginFactory* KoPluginLoader::loadSinglePlugin(const std::vector<std::pair<QSt
}),
offers.end());
- auto versionFromPlugin = [] (const KoJsonTrader::Plugin &plugin) {
- QJsonObject json = plugin.metaData().value("MetaData").toObject();
- QVariant version = json.value("X-Krita-Version");
- return version.toString().toInt();
- };
-
- auto versionCompareLess = [&] (const KoJsonTrader::Plugin &lhs, const KoJsonTrader::Plugin &rhs) {
- return versionFromPlugin(lhs) < versionFromPlugin(rhs);
- };
-
auto it = std::max_element(offers.begin(), offers.end(), versionCompareLess);
if (it != offers.end()) {
diff --git a/libs/koplugin/KoPluginLoader.h b/libs/koplugin/KoPluginLoader.h
index abb25c42b5..c80657bda8 100644
--- a/libs/koplugin/KoPluginLoader.h
+++ b/libs/koplugin/KoPluginLoader.h
@@ -62,7 +62,7 @@ public:
* stating explicitly which plugins are wanted.
*/
struct PluginsConfig {
- PluginsConfig() : group(0), whiteList(0), blacklist(0) {}
+ PluginsConfig() : group(nullptr), blacklist(nullptr) {}
/**
* The properties are retrieved from the config using the following construct;
* /code
@@ -70,14 +70,13 @@ public:
* /endcode
* For most cases you can pass the string "krita" into this variable.
*/
- const char * group;
- /// This contains the variable name for the list of plugins (by library name) the user wants to load
- const char * whiteList;
+ const char * group {nullptr };
/// This contains the variable name for the list of plugins (by library name) that will not be loaded
- const char * blacklist;
- /// A registry can state it wants to load a default set of plugins instead of all plugins
- /// when the application starts the first time. Append all such plugin (library) names to this list.
- QStringList defaults;
+ const char * blacklist {nullptr};
+
+ inline bool isValid() const {
+ return group && blacklist;
+ }
};
~KoPluginLoader() override;
@@ -89,9 +88,8 @@ public:
static KoPluginLoader * instance();
/**
- * Load all plugins that conform to the versiontype and versionstring,
- * for instance:
- * KoPluginLoader::instance()->load("Krita/Flake", "([X-Flake-PluginVersion] == 28)");
+ * Load all plugins that conform to the versiontype, for instance:
+ * KoPluginLoader::instance()->load("Krita/Flake");
* This method allows you to optionally limit the plugins that are loaded by version, but also
* using a user configurable set of config options.
* If you pass a PluginsConfig struct only those plugins are loaded that are specified in the
diff --git a/libs/koplugin/tests/CMakeLists.txt b/libs/koplugin/tests/CMakeLists.txt
new file mode 100644
index 0000000000..3fea9d24ac
--- /dev/null
+++ b/libs/koplugin/tests/CMakeLists.txt
@@ -0,0 +1,52 @@
+include(KritaAddBrokenUnitTest)
+
+kis_add_library(dummytrivialinterface SHARED DummyTrivialInterface.cpp)
+target_link_libraries(dummytrivialinterface PRIVATE Qt::Core)
+generate_export_header(dummytrivialinterface BASE_NAME dummytrivialinterface)
+
+macro(add_dummy_plugin target_name plugin_id plugin_version plugin_json_file)
+ set(dummy_plugin_SRCS
+ DummyPlugin.cpp
+ )
+
+ kis_add_library(${target_name} MODULE ${dummy_plugin_SRCS})
+
+ set_target_properties(${target_name}
+ PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dummyplugins
+ )
+
+ target_compile_definitions(${target_name}
+ PRIVATE
+ DUMMY_PLUGIN_ID="${plugin_id}"
+ DUMMY_PLUGIN_VERSION=${plugin_version}
+ DUMMY_PLUGIN_JSON_FILE="${plugin_json_file}"
+ )
+
+ target_link_libraries(${target_name}
+ PRIVATE
+ Qt::Core
+ kritaglobal
+ KF${KF_MAJOR}::CoreAddons
+ dummytrivialinterface
+ )
+endmacro()
+
+add_dummy_plugin(kritadummyplugin1 "dummyplugin1" 1 "dummyplugin1.json")
+add_dummy_plugin(kritadummyplugin2 "dummyplugin2" 1 "dummyplugin2.json")
+add_dummy_plugin(kritadummyplugin2_ver2 "dummyplugin2" 2 "dummyplugin2_ver2.json")
+add_dummy_plugin(kritadummyplugin3 "dummyplugin3" 3 "dummyplugin3_ver_as_int.json")
+
+kis_add_test(
+ KoPluginLoaderTest.cpp
+ TEST_NAME KoPluginLoaderTest
+ LINK_LIBRARIES kritaplugin kritaglobal kritatestsdk KF${KF_MAJOR}::CoreAddons KF${KF_MAJOR}::ConfigCore dummytrivialinterface
+ NAME_PREFIX "libs-koplugin-"
+)
+
+target_compile_definitions(KoPluginLoaderTest
+ PRIVATE
+ DUMMY_PLUGINS_PATH=${CMAKE_CURRENT_BINARY_DIR}/dummyplugins
+ )
+
+add_dependencies(KoPluginLoaderTest kritadummyplugin1 kritadummyplugin2 kritadummyplugin2_ver2 kritadummyplugin3)
\ No newline at end of file
diff --git a/libs/koplugin/tests/DummyPlugin.cpp b/libs/koplugin/tests/DummyPlugin.cpp
new file mode 100644
index 0000000000..bc31959925
--- /dev/null
+++ b/libs/koplugin/tests/DummyPlugin.cpp
@@ -0,0 +1,19 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "DummyPlugin.h"
+
+#include <kpluginfactory.h>
+
+K_PLUGIN_FACTORY_WITH_JSON(DummyPluginFactory, DUMMY_PLUGIN_JSON_FILE, registerPlugin<DummyPlugin>();)
+
+DummyPlugin::DummyPlugin(QObject *parent, const QVariantList &)
+ : DummyTrivialInterface(parent)
+{
+}
+
+#include <DummyPlugin.moc>
+#include <moc_DummyPlugin.cpp>
diff --git a/libs/koplugin/tests/DummyPlugin.h b/libs/koplugin/tests/DummyPlugin.h
new file mode 100644
index 0000000000..6d26e2305d
--- /dev/null
+++ b/libs/koplugin/tests/DummyPlugin.h
@@ -0,0 +1,24 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef DUMMY_PLUGIN_H
+#define DUMMY_PLUGIN_H
+
+#include <QObject>
+#include <QString>
+#include "DummyTrivialInterface.h"
+
+class DummyPlugin : public DummyTrivialInterface
+{
+ Q_OBJECT
+public:
+ DummyPlugin(QObject *parent, const QVariantList &);
+
+ QString name() const override { return DUMMY_PLUGIN_ID; }
+ int version() const override { return DUMMY_PLUGIN_VERSION; }
+};
+
+#endif // DUMMY_PLUGIN_H
\ No newline at end of file
diff --git a/libs/koplugin/tests/DummyTrivialInterface.cpp b/libs/koplugin/tests/DummyTrivialInterface.cpp
new file mode 100644
index 0000000000..5795db071d
--- /dev/null
+++ b/libs/koplugin/tests/DummyTrivialInterface.cpp
@@ -0,0 +1,13 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <DummyTrivialInterface.h>
+
+DummyTrivialInterface::~DummyTrivialInterface()
+{
+}
+
+#include <DummyTrivialInterface.moc>
\ No newline at end of file
diff --git a/libs/koplugin/tests/DummyTrivialInterface.h b/libs/koplugin/tests/DummyTrivialInterface.h
new file mode 100644
index 0000000000..69f3a6c2f4
--- /dev/null
+++ b/libs/koplugin/tests/DummyTrivialInterface.h
@@ -0,0 +1,25 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef DUMMY_TRIVIAL_INTERFACE_H
+#define DUMMY_TRIVIAL_INTERFACE_H
+
+#include <QObject>
+#include <QString>
+
+#include <dummytrivialinterface_export.h>
+
+class DUMMYTRIVIALINTERFACE_EXPORT DummyTrivialInterface : public QObject
+{
+ Q_OBJECT
+public:
+ using QObject::QObject;
+ ~DummyTrivialInterface() override;
+ virtual QString name() const = 0;
+ virtual int version() const = 0;
+};
+
+#endif // DUMMY_TRIVIAL_INTERFACE_H
\ No newline at end of file
diff --git a/libs/koplugin/tests/KoPluginLoaderTest.cpp b/libs/koplugin/tests/KoPluginLoaderTest.cpp
new file mode 100644
index 0000000000..63a0eb84b6
--- /dev/null
+++ b/libs/koplugin/tests/KoPluginLoaderTest.cpp
@@ -0,0 +1,113 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Your Name <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "KoPluginLoaderTest.h"
+#include "KoPluginLoader.h"
+#include <QTest>
+
+#include <kpluginfactory.h>
+#include <DummyTrivialInterface.h>
+
+#include <kconfiggroup.h>
+#include <ksharedconfig.h>
+#include <KisMpl.h>
+
+#include <kis_debug.h>
+
+void KoPluginLoaderTest::initTestCase()
+{
+ qDebug() << QT_STRINGIFY(DUMMY_PLUGINS_PATH);
+ qputenv("KRITA_PLUGIN_PATH", QT_STRINGIFY(DUMMY_PLUGINS_PATH));
+}
+
+void KoPluginLoaderTest::testLoadSinglePlugin_data()
+{
+ QTest::addColumn<QString>("requestedPluginId");
+ QTest::addColumn<QString>("expectedPluginId");
+ QTest::addColumn<int>("expectedVersion");
+
+ QTest::addRow("load_normal") << "dummyplugin1" << "dummyplugin1" << 1;
+ QTest::addRow("load_latest_version") << "dummyplugin2" << "dummyplugin2" << 2;
+ QTest::addRow("load_version_as_int") << "dummyplugin3" << "dummyplugin3" << 3;
+}
+
+void KoPluginLoaderTest::testLoadSinglePlugin()
+{
+ QFETCH(QString, requestedPluginId);
+ QFETCH(QString, expectedPluginId);
+ QFETCH(int, expectedVersion);
+
+ KoPluginLoader *loader = KoPluginLoader::instance();
+
+ KPluginFactory *factory = loader->loadSinglePlugin(requestedPluginId, "Krita/DummyPlugin");
+ QVERIFY(factory);
+
+ std::unique_ptr<DummyTrivialInterface> plugin1(factory->create<DummyTrivialInterface>());
+ QVERIFY(plugin1);
+
+ QCOMPARE(plugin1->version(), expectedVersion);
+ QCOMPARE(plugin1->name(), expectedPluginId);
+}
+
+void KoPluginLoaderTest::testLoadAll_data()
+{
+ QTest::addColumn<QStringList>("blacklistedIds");
+
+ QTest::addRow("load_all") << QStringList{};
+ QTest::addRow("load_blacklist") << QStringList{"dummyplugin1"};
+ QTest::addRow("load_blacklist_duplicated") << QStringList{"dummyplugin2"};
+}
+
+void KoPluginLoaderTest::testLoadAll()
+{
+ QFETCH(QStringList, blacklistedIds);
+
+ KoPluginLoader::PluginsConfig config;
+
+ if (!blacklistedIds.isEmpty()) {
+ config.group = "dummy";
+ config.blacklist = "dummyblacklist";
+
+ KConfigGroup configGroup(KSharedConfig::openConfig(), config.group);
+ configGroup.writeEntry(config.blacklist, blacklistedIds);
+ }
+
+ std::unique_ptr<QObject> parent(new QObject);
+
+ KoPluginLoader *loader = KoPluginLoader::instance();
+ loader->load("Krita/DummyPlugin", config, parent.get(), false);
+
+ std::vector<std::pair<QString, int>> childrenIds;
+ for (QObject *obj : parent->children()) {
+ DummyTrivialInterface *iface = qobject_cast<DummyTrivialInterface*>(obj);
+ QVERIFY(iface);
+ childrenIds.emplace_back(iface->name(), iface->version());
+ }
+ std::sort(childrenIds.begin(), childrenIds.end());
+
+ std::vector<std::pair<QString, int>> expectedIds = {
+ {"dummyplugin1", 1},
+ {"dummyplugin2", 2},
+ {"dummyplugin3", 3}
+ };
+
+ if (!blacklistedIds.isEmpty()) {
+ auto it = expectedIds.begin();
+ while (it != expectedIds.end()) {
+ if (blacklistedIds.contains(it->first)) {
+ it = expectedIds.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
+ KSharedConfig::openConfig()->deleteGroup(config.group);
+ }
+
+ QCOMPARE(childrenIds, expectedIds);
+}
+
+QTEST_GUILESS_MAIN(KoPluginLoaderTest)
\ No newline at end of file
diff --git a/libs/koplugin/tests/KoPluginLoaderTest.h b/libs/koplugin/tests/KoPluginLoaderTest.h
new file mode 100644
index 0000000000..55c0c2f924
--- /dev/null
+++ b/libs/koplugin/tests/KoPluginLoaderTest.h
@@ -0,0 +1,26 @@
+/*
+* SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef KO_PLUGIN_LOADER_TEST_H
+#define KO_PLUGIN_LOADER_TEST_H
+
+#include <QObject>
+
+class KoPluginLoaderTest : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void initTestCase();
+
+ void testLoadSinglePlugin_data();
+ void testLoadSinglePlugin();
+
+ void testLoadAll_data();
+ void testLoadAll();
+};
+
+#endif // KO_PLUGIN_LOADER_TEST_H
\ No newline at end of file
diff --git a/libs/koplugin/tests/dummyplugin1.json b/libs/koplugin/tests/dummyplugin1.json
new file mode 100644
index 0000000000..fe87e913a1
--- /dev/null
+++ b/libs/koplugin/tests/dummyplugin1.json
@@ -0,0 +1,10 @@
+{
+ "Id": "dummyplugin1",
+ "Type": "Service",
+ "X-KDE-Library": "dummyplugin",
+ "X-KDE-PluginInfo-Name": "DummyPlugin",
+ "X-KDE-ServiceTypes": [
+ "Krita/DummyPlugin"
+ ],
+ "X-Krita-Version": "1"
+}
diff --git a/libs/koplugin/tests/dummyplugin2.json b/libs/koplugin/tests/dummyplugin2.json
new file mode 100644
index 0000000000..e0d8be1829
--- /dev/null
+++ b/libs/koplugin/tests/dummyplugin2.json
@@ -0,0 +1,10 @@
+{
+ "Id": "dummyplugin2",
+ "Type": "Service",
+ "X-KDE-Library": "dummyplugin",
+ "X-KDE-PluginInfo-Name": "DummyPlugin",
+ "X-KDE-ServiceTypes": [
+ "Krita/DummyPlugin"
+ ],
+ "X-Krita-Version": "1"
+}
diff --git a/libs/koplugin/tests/dummyplugin2_ver2.json b/libs/koplugin/tests/dummyplugin2_ver2.json
new file mode 100644
index 0000000000..95d9424394
--- /dev/null
+++ b/libs/koplugin/tests/dummyplugin2_ver2.json
@@ -0,0 +1,10 @@
+{
+ "Id": "dummyplugin2",
+ "Type": "Service",
+ "X-KDE-Library": "dummyplugin",
+ "X-KDE-PluginInfo-Name": "DummyPlugin",
+ "X-KDE-ServiceTypes": [
+ "Krita/DummyPlugin"
+ ],
+ "X-Krita-Version": "2"
+}
diff --git a/libs/koplugin/tests/dummyplugin3_ver_as_int.json b/libs/koplugin/tests/dummyplugin3_ver_as_int.json
new file mode 100644
index 0000000000..37ac98835e
--- /dev/null
+++ b/libs/koplugin/tests/dummyplugin3_ver_as_int.json
@@ -0,0 +1,10 @@
+{
+ "Id": "dummyplugin3",
+ "Type": "Service",
+ "X-KDE-Library": "dummyplugin",
+ "X-KDE-PluginInfo-Name": "DummyPlugin",
+ "X-KDE-ServiceTypes": [
+ "Krita/DummyPlugin"
+ ],
+ "X-Krita-Version": 3
+}
diff --git a/libs/pigment/KoColorSpaceRegistry.cpp b/libs/pigment/KoColorSpaceRegistry.cpp
index 18c7d33f19..7c5ed639d8 100644
--- a/libs/pigment/KoColorSpaceRegistry.cpp
+++ b/libs/pigment/KoColorSpaceRegistry.cpp
@@ -180,13 +180,11 @@ void KoColorSpaceRegistry::init()
}
KoPluginLoader::PluginsConfig config;
- config.whiteList = "ColorSpacePlugins";
config.blacklist = "ColorSpacePluginsDisabled";
config.group = "krita";
KoPluginLoader::instance()->load("Krita/ColorSpace", config);
KoPluginLoader::PluginsConfig configExtensions;
- configExtensions.whiteList = "ColorSpaceExtensionsPlugins";
configExtensions.blacklist = "ColorSpaceExtensionsPluginsDisabled";
configExtensions.group = "krita";
KoPluginLoader::instance()->load("Krita/ColorSpaceExtension", configExtensions);
diff --git a/plugins/dockers/svgcollectiondocker/svgcollectiondocker.json b/plugins/dockers/svgcollectiondocker/svgcollectiondocker.json
index 57758ed686..42ae5d8de7 100644
--- a/plugins/dockers/svgcollectiondocker/svgcollectiondocker.json
+++ b/plugins/dockers/svgcollectiondocker/svgcollectiondocker.json
@@ -1,8 +1,7 @@
{
"Id": "SVG Collection Docker",
"Type": "Service",
- "X-Flake-MinVersion": "28",
- "X-Flake-PluginVersion": "28",
+ "X-Krita-Version": "28",
"X-KDE-Library": "kritasvgcollectiondocker",
"X-KDE-ServiceTypes": [
"Krita/Dock"
diff --git a/plugins/flake/imageshape/krita_shape_image.json b/plugins/flake/imageshape/krita_shape_image.json
index 25c14f2abf..e34f1d5649 100644
--- a/plugins/flake/imageshape/krita_shape_image.json
+++ b/plugins/flake/imageshape/krita_shape_image.json
@@ -1,8 +1,7 @@
{
"Id": "Static Vector Shape",
"Type": "Service",
- "X-Flake-MinVersion": "28",
- "X-Flake-PluginVersion": "28",
+ "X-Krita-Version": "28",
"X-KDE-Library": "krita_shape_image",
"X-KDE-PluginInfo-Name": "imageshape",
"X-KDE-ServiceTypes": [
diff --git a/plugins/flake/pathshapes/calligra_shape_paths.json b/plugins/flake/pathshapes/calligra_shape_paths.json
index 3cf7f4a7ee..e5d8369306 100644
--- a/plugins/flake/pathshapes/calligra_shape_paths.json
+++ b/plugins/flake/pathshapes/calligra_shape_paths.json
@@ -2,8 +2,7 @@
"Icon": "",
"Id": "Path Shapes",
"Type": "Service",
- "X-Flake-MinVersion": "28",
- "X-Flake-PluginVersion": "28",
+ "X-Krita-Version": "28",
"X-KDE-Library": "krita_shape_paths",
"X-KDE-PluginInfo-Name": "pathshapes",
"X-KDE-ServiceTypes": [
diff --git a/plugins/tools/defaulttool/calligra_tool_defaults.json b/plugins/tools/defaulttool/calligra_tool_defaults.json
index c29908d463..5ecd20bca6 100644
--- a/plugins/tools/defaulttool/calligra_tool_defaults.json
+++ b/plugins/tools/defaulttool/calligra_tool_defaults.json
@@ -1,8 +1,7 @@
{
"Id": "Default Flake Tools",
"Type": "Service",
- "X-Flake-MinVersion": "28",
- "X-Flake-PluginVersion": "28",
+ "X-Krita-Version": "28",
"X-KDE-Library": "krita_flaketools",
"X-KDE-PluginInfo-Name": "defaulttools",
"X-KDE-ServiceTypes": [
diff --git a/plugins/tools/karbonplugins/tools/karbon_tools.json b/plugins/tools/karbonplugins/tools/karbon_tools.json
index 391d90e5b3..414d973a59 100644
--- a/plugins/tools/karbonplugins/tools/karbon_tools.json
+++ b/plugins/tools/karbonplugins/tools/karbon_tools.json
@@ -1,8 +1,7 @@
{
"Id": "Karbon Tools",
"Type": "Service",
- "X-Flake-MinVersion": "28",
- "X-Flake-PluginVersion": "28",
+ "X-Krita-Version": "28",
"X-KDE-Library": "krita_karbon_tools",
"X-KDE-PluginInfo-Name": "krita_karbontools",
"X-KDE-ServiceTypes": [
diff --git a/plugins/tools/svgtexttool/krita_tool_svgtext.json b/plugins/tools/svgtexttool/krita_tool_svgtext.json
index 205c28fa72..0906915031 100644
--- a/plugins/tools/svgtexttool/krita_tool_svgtext.json
+++ b/plugins/tools/svgtexttool/krita_tool_svgtext.json
@@ -1,8 +1,7 @@
{
"Id": "SvgTextTool",
"Type": "Service",
- "X-Flake-MinVersion": "28",
- "X-Flake-PluginVersion": "28",
+ "X-Krita-Version": "28",
"X-KDE-Library": "krita_tool_svgtext",
"X-KDE-PluginInfo-Name": "svgtexttool",
"X-KDE-ServiceTypes": [