Port from KPluginLoader::pluginsById to KPluginMetaData::pluginById

The latter gives us only a single plugin which makes the code a bit more concise
This commit is contained in:
Nicolas Fella 2021-07-22 22:59:13 +02:00
parent 05f3939cf1
commit 25b85607d0
6 changed files with 20 additions and 20 deletions

View file

@ -62,12 +62,12 @@ WaylandTestApplication::WaylandTestApplication(OperationMode mode, int &argc, ch
removeLibraryPath(ownPath); removeLibraryPath(ownPath);
addLibraryPath(ownPath); addLibraryPath(ownPath);
const auto plugins = KPluginLoader::findPluginsById(QStringLiteral("org.kde.kwin.waylandbackends"), "KWinWaylandVirtualBackend"); const KPluginMetaData plugin = KPluginMetaData::findPluginById(QStringLiteral("org.kde.kwin.waylandbackends"), "KWinWaylandVirtualBackend");
if (plugins.empty()) { if (!plugin.isValid()) {
quit(); quit();
return; return;
} }
initPlatform(plugins.first()); initPlatform(plugin);
WaylandServer::create(this); WaylandServer::create(this);
setProcessStartupEnvironment(QProcessEnvironment::systemEnvironment()); setProcessStartupEnvironment(QProcessEnvironment::systemEnvironment());
} }

View file

@ -43,13 +43,13 @@ X11TestApplication::X11TestApplication(int &argc, char **argv)
removeLibraryPath(ownPath); removeLibraryPath(ownPath);
addLibraryPath(ownPath); addLibraryPath(ownPath);
const auto plugins = KPluginLoader::findPluginsById(QStringLiteral("org.kde.kwin.platforms"), const KPluginMetaData plugin = KPluginMetaData::findPluginById(QStringLiteral("org.kde.kwin.platforms"),
QStringLiteral("KWinX11Platform")); QStringLiteral("KWinX11Platform"));
if (plugins.empty()) { if (!plugin.isValid()) {
quit(); quit();
return; return;
} }
initPlatform(plugins.first()); initPlatform(plugin);
} }
X11TestApplication::~X11TestApplication() X11TestApplication::~X11TestApplication()

View file

@ -137,13 +137,13 @@ void DecorationBridge::init()
void DecorationBridge::initPlugin() void DecorationBridge::initPlugin()
{ {
const auto offers = KPluginLoader::findPluginsById(s_pluginName, m_plugin); const KPluginMetaData metaData = KPluginMetaData::findPluginById(s_pluginName, m_plugin);
if (offers.isEmpty()) { if (!metaData.isValid()) {
qCWarning(KWIN_DECORATIONS) << "Could not locate decoration plugin"; qCWarning(KWIN_DECORATIONS) << "Could not locate decoration plugin" << m_plugin;
return; return;
} }
qCDebug(KWIN_DECORATIONS) << "Trying to load decoration plugin: " << offers.first().fileName(); qCDebug(KWIN_DECORATIONS) << "Trying to load decoration plugin: " << metaData.fileName();
KPluginLoader loader(offers.first().fileName()); KPluginLoader loader(metaData.fileName());
KPluginFactory *factory = loader.factory(); KPluginFactory *factory = loader.factory();
if (!factory) { if (!factory) {
qCWarning(KWIN_DECORATIONS) << "Error loading plugin:" << loader.errorString(); qCWarning(KWIN_DECORATIONS) << "Error loading plugin:" << loader.errorString();

View file

@ -605,13 +605,13 @@ QModelIndex EffectsModel::findByPluginId(const QString &pluginId) const
static KCModule *loadBinaryConfig(const QString &configModule, QObject *parent) static KCModule *loadBinaryConfig(const QString &configModule, QObject *parent)
{ {
const QVector<KPluginMetaData> offers = KPluginLoader::findPluginsById(QStringLiteral("kwin/effects/configs/"), configModule); const KPluginMetaData metaData = KPluginMetaData::findPluginById(QStringLiteral("kwin/effects/configs/"), configModule);
if (offers.isEmpty()) { if (!metaData.isValid()) {
return nullptr; return nullptr;
} }
KPluginLoader loader(offers.first().fileName()); KPluginLoader loader(metaData.fileName());
KPluginFactory *factory = loader.factory(); KPluginFactory *factory = loader.factory();
return factory->create<KCModule>(parent); return factory->create<KCModule>(parent);

View file

@ -466,13 +466,13 @@ int main(int argc, char * argv[])
} }
// find and load the X11 platform plugin // find and load the X11 platform plugin
const auto plugins = KPluginLoader::findPluginsById(QStringLiteral("org.kde.kwin.platforms"), const KPluginMetaData plugin = KPluginMetaData::findPluginById(QStringLiteral("org.kde.kwin.platforms"), QStringLiteral("KWinX11Platform"));
QStringLiteral("KWinX11Platform"));
if (plugins.isEmpty()) { if (!plugin.isValid()) {
std::cerr << "FATAL ERROR: KWin could not find the KWinX11Platform plugin" << std::endl; std::cerr << "FATAL ERROR: KWin could not find the KWinX11Platform plugin" << std::endl;
return 1; return 1;
} }
a.initPlatform(plugins.first()); a.initPlatform(plugin);
if (!a.platform()) { if (!a.platform()) {
std::cerr << "FATAL ERROR: could not instantiate the platform plugin" << std::endl; std::cerr << "FATAL ERROR: could not instantiate the platform plugin" << std::endl;
return 1; return 1;

View file

@ -127,8 +127,8 @@ bool PluginManager::loadStaticPlugin(const QString &pluginId)
bool PluginManager::loadDynamicPlugin(const QString &pluginId) bool PluginManager::loadDynamicPlugin(const QString &pluginId)
{ {
const auto offers = KPluginLoader::findPluginsById(s_pluginDirectory, pluginId); const KPluginMetaData metadata = KPluginMetaData::findPluginById(s_pluginDirectory, pluginId);
for (const KPluginMetaData &metadata : offers) { if (metadata.isValid()) {
if (loadDynamicPlugin(metadata)) { if (loadDynamicPlugin(metadata)) {
return true; return true;
} }