Fully port away from KPluginLoader
This commit is contained in:
parent
e431b453b6
commit
dffbfcc9f7
13 changed files with 14 additions and 44 deletions
|
@ -12,7 +12,6 @@
|
||||||
// KDE
|
// KDE
|
||||||
#include <KConfig>
|
#include <KConfig>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KPluginLoader>
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
|
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
@ -37,7 +36,7 @@ X11TestApplication::X11TestApplication(int &argc, char **argv)
|
||||||
setX11Connection(QX11Info::connection());
|
setX11Connection(QX11Info::connection());
|
||||||
setX11RootWindow(QX11Info::appRootWindow());
|
setX11RootWindow(QX11Info::appRootWindow());
|
||||||
|
|
||||||
// move directory containing executable to front, so that KPluginLoader prefers the plugins in
|
// move directory containing executable to front, so that KPluginMetaData::findPluginById prefers the plugins in
|
||||||
// the build dir over system installed ones
|
// the build dir over system installed ones
|
||||||
const auto ownPath = libraryPaths().last();
|
const auto ownPath = libraryPaths().last();
|
||||||
removeLibraryPath(ownPath);
|
removeLibraryPath(ownPath);
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include <KGlobalAccel>
|
#include <KGlobalAccel>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
#include <KNotification>
|
#include <KNotification>
|
||||||
#include <KSelectionOwner>
|
#include <KSelectionOwner>
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
// Frameworks
|
// Frameworks
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
#include <KPluginLoader>
|
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QMetaProperty>
|
#include <QMetaProperty>
|
||||||
|
@ -143,13 +142,12 @@ void DecorationBridge::initPlugin()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCDebug(KWIN_DECORATIONS) << "Trying to load decoration plugin: " << metaData.fileName();
|
qCDebug(KWIN_DECORATIONS) << "Trying to load decoration plugin: " << metaData.fileName();
|
||||||
KPluginLoader loader(metaData.fileName());
|
auto factoryResult = KPluginFactory::loadFactory(metaData);
|
||||||
KPluginFactory *factory = loader.factory();
|
if (!factoryResult) {
|
||||||
if (!factory) {
|
qCWarning(KWIN_DECORATIONS) << "Error loading plugin:" << factoryResult.errorText;
|
||||||
qCWarning(KWIN_DECORATIONS) << "Error loading plugin:" << loader.errorString();
|
|
||||||
} else {
|
} else {
|
||||||
m_factory = factory;
|
m_factory = factoryResult.plugin;
|
||||||
loadMetaData(loader.metaData().value(QStringLiteral("MetaData")).toObject());
|
loadMetaData(metaData.rawData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
// KDE
|
// KDE
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPackage/Package>
|
#include <KPackage/Package>
|
||||||
#include <KPackage/PackageLoader>
|
#include <KPackage/PackageLoader>
|
||||||
// Qt
|
// Qt
|
||||||
|
@ -381,12 +380,12 @@ EffectPluginFactory *PluginEffectLoader::factory(const KPluginMetaData &info) co
|
||||||
if (!info.isValid()) {
|
if (!info.isValid()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
KPluginLoader loader(info.fileName());
|
QPluginLoader loader(info.fileName());
|
||||||
if (loader.metaData().value("IID").toString() != EffectPluginFactory_iid) {
|
if (loader.metaData().value("IID").toString() != EffectPluginFactory_iid) {
|
||||||
qCDebug(KWIN_CORE) << info.pluginId() << " has not matching plugin version, expected " << PluginFactory_iid << "got " << loader.metaData().value("IID");
|
qCDebug(KWIN_CORE) << info.pluginId() << " has not matching plugin version, expected " << PluginFactory_iid << "got " << loader.metaData().value("IID");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
KPluginFactory *factory = loader.factory();
|
KPluginFactory *factory = qobject_cast<KPluginFactory *>(loader.instance());
|
||||||
if (!factory) {
|
if (!factory) {
|
||||||
qCDebug(KWIN_CORE) << "Did not get KPluginFactory for " << info.pluginId();
|
qCDebug(KWIN_CORE) << "Did not get KPluginFactory for " << info.pluginId();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KPackage/PackageLoader>
|
#include <KPackage/PackageLoader>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginInfo>
|
#include <KPluginInfo>
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
|
@ -630,21 +629,13 @@ static KCModule *loadBinaryConfig(const QString &configModule, QObject *parent)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
KPluginLoader loader(metaData.fileName());
|
return KPluginFactory::instantiatePlugin<KCModule>(metaData, parent).plugin;
|
||||||
KPluginFactory *factory = loader.factory();
|
|
||||||
|
|
||||||
return factory->create<KCModule>(parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static KCModule *findScriptedConfig(const QString &pluginId, QObject *parent)
|
static KCModule *findScriptedConfig(const QString &pluginId, QObject *parent)
|
||||||
{
|
{
|
||||||
KPluginLoader loader(QStringLiteral("kwin/effects/configs/kcm_kwin4_genericscripted"));
|
KPluginMetaData metaData(QStringLiteral("kwin/effects/configs/kcm_kwin4_genericscripted"));
|
||||||
KPluginFactory *factory = loader.factory();
|
return KPluginFactory::instantiatePlugin<KCModule>(metaData, parent, QVariantList{pluginId}).plugin;
|
||||||
if (!factory) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return factory->create<KCModule>(parent, QVariantList{pluginId});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsModel::requestConfigure(const QModelIndex &index, QWindow *transientParent)
|
void EffectsModel::requestConfigure(const QModelIndex &index, QWindow *transientParent)
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <KDecoration2/Decoration>
|
#include <KDecoration2/Decoration>
|
||||||
|
|
||||||
#include <KCModule>
|
#include <KCModule>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
|
|
||||||
|
@ -111,8 +110,7 @@ void PreviewBridge::createFactory()
|
||||||
const auto offers = KPluginMetaData::findPlugins(s_pluginName);
|
const auto offers = KPluginMetaData::findPlugins(s_pluginName);
|
||||||
auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { return plugin.pluginId() == m_plugin; });
|
auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { return plugin.pluginId() == m_plugin; });
|
||||||
if (item != offers.constEnd()) {
|
if (item != offers.constEnd()) {
|
||||||
KPluginLoader loader(item->fileName());
|
m_factory = KPluginFactory::loadFactory(*item).plugin;
|
||||||
m_factory = loader.factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setValid(!m_factory.isNull());
|
setValid(!m_factory.isNull());
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <KDecoration2/DecorationSettings>
|
#include <KDecoration2/DecorationSettings>
|
||||||
#include <KDecoration2/DecorationThemeProvider>
|
#include <KDecoration2/DecorationThemeProvider>
|
||||||
// KDE
|
// KDE
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
// Qt
|
// Qt
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <kaboutdata.h>
|
#include <kaboutdata.h>
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginLoader>
|
|
||||||
|
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
|
@ -398,15 +398,7 @@ void KWinTabBoxConfig::configureEffectClicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KCModule *kcm = nullptr;
|
KCModule *kcm = KPluginFactory::instantiatePlugin<KCModule>(plugins.first(), configDialog).plugin;
|
||||||
|
|
||||||
KPluginLoader loader(plugins.first().fileName());
|
|
||||||
KPluginFactory *factory = loader.factory();
|
|
||||||
if (!factory) {
|
|
||||||
qWarning() << "Error loading plugin:" << loader.errorString();
|
|
||||||
} else {
|
|
||||||
kcm = factory->create<KCModule>(configDialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!kcm) {
|
if (!kcm) {
|
||||||
delete configDialog;
|
delete configDialog;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include <KCrash>
|
#include <KCrash>
|
||||||
#include <KDesktopFile>
|
#include <KDesktopFile>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
#include <KQuickAddons/QtQuickSettings>
|
#include <KQuickAddons/QtQuickSettings>
|
||||||
#include <KShell>
|
#include <KShell>
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KCrash>
|
#include <KCrash>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
#include <KSelectionOwner>
|
#include <KSelectionOwner>
|
||||||
#include <KQuickAddons/QtQuickSettings>
|
#include <KQuickAddons/QtQuickSettings>
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginLoader>
|
|
||||||
#include <KPluginMetaData>
|
#include <KPluginMetaData>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -144,7 +143,7 @@ bool PluginManager::loadDynamicPlugin(const KPluginMetaData &metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString pluginId = metadata.pluginId();
|
const QString pluginId = metadata.pluginId();
|
||||||
KPluginLoader pluginLoader(metadata.fileName());
|
QPluginLoader pluginLoader(metadata.fileName());
|
||||||
if (pluginLoader.metaData().value("IID").toString() != PluginFactory_iid) {
|
if (pluginLoader.metaData().value("IID").toString() != PluginFactory_iid) {
|
||||||
qCWarning(KWIN_CORE) << pluginId << "has mismatching plugin version";
|
qCWarning(KWIN_CORE) << pluginId << "has mismatching plugin version";
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue