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);