PluginLoader: improve error message about plugin version compatibility
Summary: The name of the actual plugin was missing, making the warning rather useless. Since this is only used within PluginLoader, I added a private function isPluginVersionCompatible(KPluginLoader), taking code from Plasma::isPluginVersionCompatible(uint). That one could probably be deprecated, although no public replacement would be available, just "use PluginLoader". Test Plan: plasmoidviewer -a org.kde.plasma.digitalclock Reviewers: mart Reviewed By: mart Tags: #frameworks Differential Revision: https://phabricator.kde.org/D1825
This commit is contained in:
parent
181869e636
commit
107c28d361
@ -45,6 +45,7 @@
|
|||||||
#include "private/storage_p.h"
|
#include "private/storage_p.h"
|
||||||
#include "private/package_p.h"
|
#include "private/package_p.h"
|
||||||
#include "private/packagestructure_p.h"
|
#include "private/packagestructure_p.h"
|
||||||
|
#include <plasma/version.h>
|
||||||
#include "debug_p.h"
|
#include "debug_p.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
@ -201,7 +202,7 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
|||||||
if (!plugins.isEmpty()) {
|
if (!plugins.isEmpty()) {
|
||||||
KPluginInfo::List lst = KPluginInfo::fromMetaData(plugins);
|
KPluginInfo::List lst = KPluginInfo::fromMetaData(plugins);
|
||||||
KPluginLoader loader(lst.first().libraryPath());
|
KPluginLoader loader(lst.first().libraryPath());
|
||||||
if (!Plasma::isPluginVersionCompatible(loader.pluginVersion())) {
|
if (!isPluginVersionCompatible(loader)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
KPluginFactory *factory = loader.factory();
|
KPluginFactory *factory = loader.factory();
|
||||||
@ -384,7 +385,7 @@ Service *PluginLoader::loadService(const QString &name, const QVariantList &args
|
|||||||
if (!plugins.isEmpty()) {
|
if (!plugins.isEmpty()) {
|
||||||
KPluginInfo::List lst = KPluginInfo::fromMetaData(plugins);
|
KPluginInfo::List lst = KPluginInfo::fromMetaData(plugins);
|
||||||
KPluginLoader loader(lst.first().libraryPath());
|
KPluginLoader loader(lst.first().libraryPath());
|
||||||
if (!Plasma::isPluginVersionCompatible(loader.pluginVersion())) {
|
if (!isPluginVersionCompatible(loader)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
KPluginFactory *factory = loader.factory();
|
KPluginFactory *factory = loader.factory();
|
||||||
@ -450,7 +451,7 @@ ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, co
|
|||||||
KService::Ptr offer = offers.first();
|
KService::Ptr offer = offers.first();
|
||||||
KPluginLoader plugin(*offer);
|
KPluginLoader plugin(*offer);
|
||||||
|
|
||||||
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
if (!isPluginVersionCompatible(plugin)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,5 +912,30 @@ KPluginInfo::List PluginLoader::standardInternalServiceInfo() const
|
|||||||
return standardInternalInfo(QStringLiteral("services"));
|
return standardInternalInfo(QStringLiteral("services"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PluginLoader::isPluginVersionCompatible(KPluginLoader &loader)
|
||||||
|
{
|
||||||
|
const quint32 version = loader.pluginVersion();
|
||||||
|
if (version == quint32(-1)) {
|
||||||
|
// unversioned, just let it through
|
||||||
|
qCWarning(LOG_PLASMA) << loader.fileName() << "unversioned plugin detected, may result in instability";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we require PLASMA_VERSION_MAJOR and PLASMA_VERSION_MINOR
|
||||||
|
const quint32 minVersion = PLASMA_MAKE_VERSION(PLASMA_VERSION_MAJOR, 0, 0);
|
||||||
|
const quint32 maxVersion = PLASMA_MAKE_VERSION(PLASMA_VERSION_MAJOR, PLASMA_VERSION_MINOR, 60);
|
||||||
|
|
||||||
|
if (version < minVersion || version > maxVersion) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
qCDebug(LOG_PLASMA) << loader.fileName() << ": this plugin is compiled against incompatible Plasma version" << version
|
||||||
|
<< "This build is compatible with" << PLASMA_VERSION_MAJOR << ".0.0 (" << minVersion
|
||||||
|
<< ") to" << PLASMA_VERSION_STRING << "(" << maxVersion << ")";
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // Plasma Namespace
|
} // Plasma Namespace
|
||||||
|
|
||||||
|
@ -471,6 +471,8 @@ protected:
|
|||||||
virtual ~PluginLoader();
|
virtual ~PluginLoader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isPluginVersionCompatible(KPluginLoader &loader);
|
||||||
|
|
||||||
PluginLoaderPrivate *const d;
|
PluginLoaderPrivate *const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user