From 928d5e63a500c56fa98f393e659d233b0762799f Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 8 Aug 2014 14:11:50 +0200 Subject: [PATCH] bool Package::hasValidStructure() const needed to differentiate between packages with structures and without before path is set --- src/plasma/package.cpp | 5 +++++ src/plasma/package.h | 8 ++++++++ src/plasma/pluginloader.cpp | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plasma/package.cpp b/src/plasma/package.cpp index 3c37a7509..6ad332167 100644 --- a/src/plasma/package.cpp +++ b/src/plasma/package.cpp @@ -72,6 +72,11 @@ Package &Package::operator=(const Package &rhs) return *this; } +bool Package::hasValidStructure() const +{ + return d->structure; +} + bool Package::isValid() const { if (!d->structure) { diff --git a/src/plasma/package.h b/src/plasma/package.h index 829fa2080..2c686d784 100644 --- a/src/plasma/package.h +++ b/src/plasma/package.h @@ -101,6 +101,14 @@ public: */ Package &operator=(const Package &rhs); + /** + * @return true if this package has a valid PackageStructure associatedw it with it. + * A package may not be valid, but have a valid structure. Useful when dealing with + * Package objects in a semi-initialized state (e.g. before calling setPath()) + * @since 5.1 + */ + bool hasValidStructure() const; + /** * @return true if all the required components exist **/ diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index bb712ed19..d2ba5ca2d 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -399,7 +399,7 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s { if (!d->isDefaultLoader) { Package p = internalLoadPackage(packageFormat, specialization); - if (p.isValid() || !p.files().isEmpty()) { + if (p.hasValidStructure()) { return p; } }