diff options
author | Frerich Raabe <raabe@froglogic.com> | 2016-01-22 14:43:05 +0100 |
---|---|---|
committer | Katja Marttila <katja.marttila@theqtcompany.com> | 2016-02-15 05:53:22 +0000 |
commit | 85883d043b4a646e73fe502d801419dc9f73a101 (patch) | |
tree | e0c5c7677543741d3abb6875a1d1b873c69d51df /src/libs/installer/packagemanagercoredata.cpp | |
parent | f80dfd7ea47fe373ef2e4dfa59ed48f0cbce3934 (diff) |
Allow calling installer.setValue() with an empty string as the value
Calls like
installer.setValue("RunProgram", "");
would fail if there was no previous setValue() call which set the
variable to a non-empty string.
In PackageManagerCoreData, the variables of the installer which are
accessible via installer.setValue and installer.value are managed in two
data structures:
* m_variables contains all variables which were set at runtime, via
installer.setValue
* m_settings contains all variables as defined in the XML configuration
file.
When calling installer.value(), it would first consider m_variables and
if the given variable name is not in that structure, it falls back to
m_settings.
What happened for calls like 'installer.setValue("RunProgram", "");' was
that the code tries to detect whether the variable already has the
specified value -- and only if it doesn't, the variable is set. To test
if the variable has the specified value, it would simply check
m_variables.value(key) and compare it with the given new value. However,
if the key was never set, 'value()' returns an empty string -- which is
equal to the new value, and hence PackageManagerCoreData::setValue()
returned false.
Fix this by first verifying that the given key exists in the m_variables
object at all before bothering to check what m_variables.value()
returns.
Change-Id: I8a2bcb74e52e05f1454945628bcf372445c91a17
Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/packagemanagercoredata.cpp')
-rw-r--r-- | src/libs/installer/packagemanagercoredata.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp index 671717d0b..3444e0247 100644 --- a/src/libs/installer/packagemanagercoredata.cpp +++ b/src/libs/installer/packagemanagercoredata.cpp @@ -160,7 +160,7 @@ bool PackageManagerCoreData::contains(const QString &key) const bool PackageManagerCoreData::setValue(const QString &key, const QString &normalizedValue) { - if (m_variables.value(key) == normalizedValue) + if (m_variables.contains(key) && m_variables.value(key) == normalizedValue) return false; m_variables.insert(key, normalizedValue); return true; |