From d7f118e589752890b712677db9d6af2c0b85251d Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 21 Nov 2020 22:50:18 +0100 Subject: [PATCH] Port packageStructure loading from KPluginTrader It will be deprecated. --- src/plasma/pluginloader.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 00c3ddc22..dee3ecdf9 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -435,14 +435,29 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s structure->d->internalStructure = internalStructure; //fallback to old structures } else { - const QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(packageFormat); - structure = KPluginTrader::createInstanceFromQuery(PluginLoaderPrivate::s_packageStructurePluginDir, QStringLiteral("Plasma/PackageStructure"), constraint, nullptr); - if (structure) { - structure->d->internalStructure = new PackageStructureWrapper(structure); + + auto filter = [packageFormat](const KPluginMetaData &md) -> bool + { + return md.value(QStringLiteral("X-KDE-PluginInfo-Name")) == packageFormat; + }; + + const QVector plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_packageStructurePluginDir, filter); + + if (!plugins.isEmpty()) { + KPluginLoader loader(plugins.first().fileName()); + KPluginFactory* factory = loader.factory(); + if (!factory) { + qWarning() << "Error loading plugin:" << loader.errorString(); + } else { + structure = factory->create(); + } + + if (structure) { + structure->d->internalStructure = new PackageStructureWrapper(structure); + } } } - if (structure) { d->structures.insert(hashkey, structure); return Package(structure);