diff options
Diffstat (limited to 'src/lib/tools')
-rw-r--r-- | src/lib/tools/profile.cpp | 24 | ||||
-rw-r--r-- | src/lib/tools/profile.h | 6 | ||||
-rw-r--r-- | src/lib/tools/setupprojectparameters.cpp | 11 |
3 files changed, 30 insertions, 11 deletions
diff --git a/src/lib/tools/profile.cpp b/src/lib/tools/profile.cpp index cb3186ae4..bef07eedb 100644 --- a/src/lib/tools/profile.cpp +++ b/src/lib/tools/profile.cpp @@ -65,9 +65,15 @@ bool Profile::exists() const /*! * \brief Returns the value for property \c key in this profile. */ -QVariant Profile::value(const QString &key, const QVariant &defaultValue) const -{ - return possiblyInheritedValue(key, defaultValue, QStringList()); +QVariant Profile::value(const QString &key, const QVariant &defaultValue, ErrorInfo *error) const +{ + try { + return possiblyInheritedValue(key, defaultValue, QStringList()); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return QVariant(); + } } /*! @@ -103,9 +109,15 @@ QString Profile::name() const * If and only if selection is Profile::KeySelectionRecursive, this will also list keys defined * in base profiles. */ -QStringList Profile::allKeys(KeySelection selection) const -{ - return allKeysInternal(selection, QStringList()); +QStringList Profile::allKeys(KeySelection selection, ErrorInfo *error) const +{ + try { + return allKeysInternal(selection, QStringList()); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return QStringList(); + } } /*! diff --git a/src/lib/tools/profile.h b/src/lib/tools/profile.h index c3b0bbfe8..740f23931 100644 --- a/src/lib/tools/profile.h +++ b/src/lib/tools/profile.h @@ -36,6 +36,7 @@ #include <QVariant> namespace qbs { +class ErrorInfo; class Settings; class QBS_EXPORT Profile @@ -44,7 +45,8 @@ public: explicit Profile(const QString &name, Settings *settings); bool exists() const; - QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const; + QVariant value(const QString &key, const QVariant &defaultValue = QVariant(), + ErrorInfo *error = 0) const; void setValue(const QString &key, const QVariant &value); void remove(const QString &key); @@ -57,7 +59,7 @@ public: void removeProfile(); enum KeySelection { KeySelectionRecursive, KeySelectionNonRecursive }; - QStringList allKeys(KeySelection selection) const; + QStringList allKeys(KeySelection selection, ErrorInfo *error = 0) const; static QString cleanName(const QString &name); diff --git a/src/lib/tools/setupprojectparameters.cpp b/src/lib/tools/setupprojectparameters.cpp index c3b00f3c4..9f6c07cb8 100644 --- a/src/lib/tools/setupprojectparameters.cpp +++ b/src/lib/tools/setupprojectparameters.cpp @@ -294,14 +294,19 @@ ErrorInfo SetupProjectParameters::expandBuildConfiguration(Settings *settings) // (2) const Profile profile(profileName, settings); - const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive); + const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive, &err); + if (err.hasError()) + return err; if (profileKeys.isEmpty()) { err.append(Internal::Tr::tr("Unknown or empty profile '%1'.").arg(profileName)); return err; } foreach (const QString &profileKey, profileKeys) { - if (!expandedConfig.contains(profileKey)) - expandedConfig.insert(profileKey, profile.value(profileKey)); + if (!expandedConfig.contains(profileKey)) { + expandedConfig.insert(profileKey, profile.value(profileKey, QVariant(), &err)); + if (err.hasError()) + return err; + } } if (d->buildConfiguration != expandedConfig) { |