plugins: Port away from deprecated version checks

Task: https://phabricator.kde.org/T14302
This commit is contained in:
Alexander Lohnau 2021-06-01 12:06:54 +02:00
parent 3c10398104
commit 9c689d7ddb
11 changed files with 15 additions and 28 deletions

View file

@ -24,7 +24,7 @@ public:
class FakeEffectPluginFactory : public KWin::EffectPluginFactory
{
Q_OBJECT
Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "fakeeffectplugin_version.json")
Q_PLUGIN_METADATA(IID "not_a_valid_version" FILE "fakeeffectplugin_version.json")
Q_INTERFACES(KPluginFactory)
public:
FakeEffectPluginFactory() {}
@ -33,7 +33,6 @@ public:
return new KWin::FakeVersionEffect();
}
};
K_EXPORT_PLUGIN_VERSION(quint32(KWIN_EFFECT_API_VERSION) - 1)
#include "fakeeffectplugin_version.moc"

View file

@ -1,6 +1,4 @@
#define KWIN_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
#define KWIN_VERSION_MINOR ${PROJECT_VERSION_MINOR}
#define KWIN_VERSION_PATCH ${PROJECT_VERSION_PATCH}
#define KWIN_PLUGIN_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
#cmakedefine KWIN_BUILD_DECORATIONS 1
#cmakedefine KWIN_BUILD_TABBOX 1

View file

@ -12,6 +12,7 @@
#include <config-kwin.h>
#include <kwineffects.h>
#include "effects/effect_builtins.h"
#include "plugin.h"
#include "scripting/scriptedeffect.h"
#include "utils.h"
// KDE
@ -345,8 +346,8 @@ EffectPluginFactory *PluginEffectLoader::factory(const KPluginMetaData &info) co
return nullptr;
}
KPluginLoader loader(info.fileName());
if (loader.pluginVersion() != KWIN_EFFECT_API_VERSION) {
qCDebug(KWIN_CORE) << info.pluginId() << " has not matching plugin version, expected " << KWIN_EFFECT_API_VERSION << "got " << loader.pluginVersion();
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");
return nullptr;
}
KPluginFactory *factory = loader.factory();

View file

@ -9,6 +9,8 @@
#ifndef KWINCONFIG_H
#define KWINCONFIG_H
#define KWIN_PLUGIN_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
/*
These should be primarily used to detect what kind of compositing

View file

@ -726,6 +726,8 @@ public:
virtual KWin::Effect *createEffect() const = 0;
};
#define EffectPluginFactory_iid "org.kde.kwin.EffectPluginFactory" KWIN_PLUGIN_VERSION_STRING
/**
* Defines an EffectPluginFactory sub class with customized isSupported and enabledByDefault methods.
*
@ -733,10 +735,8 @@ public:
* the simplified KWIN_EFFECT_FACTORY, KWIN_EFFECT_FACTORY_SUPPORTED or KWIN_EFFECT_FACTORY_ENABLED
* macros which create an EffectPluginFactory with a useable default value.
*
* The macro also adds a useable K_EXPORT_PLUGIN_VERSION to the definition. KWin will not load
* any Effect with a non-matching plugin version. This API is not providing binary compatibility
* and thus the effect plugin must be compiled against the same kwineffects library version as
* KWin.
* This API is not providing binary compatibility and thus the effect plugin must be compiled against
* the same kwineffects library version as KWin.
*
* @param factoryName The name to be used for the EffectPluginFactory
* @param className The class name of the Effect sub class which is to be created by the factory
@ -748,7 +748,7 @@ public:
class factoryName : public KWin::EffectPluginFactory \
{ \
Q_OBJECT \
Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE jsonFile) \
Q_PLUGIN_METADATA(IID EffectPluginFactory_iid FILE jsonFile) \
Q_INTERFACES(KPluginFactory) \
public: \
explicit factoryName() {} \
@ -762,8 +762,7 @@ public:
KWin::Effect *createEffect() const override { \
return new className(); \
} \
}; \
K_EXPORT_PLUGIN_VERSION(quint32(KWIN_EFFECT_API_VERSION))
};
#define KWIN_EFFECT_FACTORY_ENABLED( factoryName, className, jsonFile, enabled ) \
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, return true;, enabled )

View file

@ -15,11 +15,7 @@
namespace KWin
{
#define KWIN_PLUGIN_API_VERSION QT_VERSION_CHECK(KWIN_VERSION_MAJOR, \
KWIN_VERSION_MINOR, \
KWIN_VERSION_PATCH)
#define PluginFactory_iid "org.kde.kwin.PluginFactoryInterface"
#define PluginFactory_iid "org.kde.kwin.PluginFactoryInterface" KWIN_PLUGIN_VERSION_STRING
/**
* The Plugin class is the baseclass for all binary compositor extensions.

View file

@ -145,7 +145,7 @@ bool PluginManager::loadDynamicPlugin(const KPluginMetaData &metadata)
const QString pluginId = metadata.pluginId();
KPluginLoader pluginLoader(metadata.fileName());
if (pluginLoader.pluginVersion() != KWIN_PLUGIN_API_VERSION) {
if (pluginLoader.metaData().value("IID").toString() != PluginFactory_iid) {
qCWarning(KWIN_CORE) << pluginId << "has mismatching plugin version";
return false;
}

View file

@ -41,6 +41,4 @@ Plugin *ColordIntegrationFactory::create() const
}
}
K_EXPORT_PLUGIN_VERSION(KWIN_PLUGIN_API_VERSION)
#include "main.moc"

View file

@ -33,6 +33,4 @@ Plugin *KRunnerIntegrationFactory::create() const
return new WindowsRunner();
}
K_EXPORT_PLUGIN_VERSION(KWIN_PLUGIN_API_VERSION)
#include "main.moc"

View file

@ -32,6 +32,4 @@ Plugin *NightColorManagerFactory::create() const
return new NightColorManager();
}
K_EXPORT_PLUGIN_VERSION(KWIN_PLUGIN_API_VERSION)
#include "main.moc"

View file

@ -41,6 +41,4 @@ Plugin *ScreencastManagerFactory::create() const
}
}
K_EXPORT_PLUGIN_VERSION(KWIN_PLUGIN_API_VERSION)
#include "main.moc"