summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-10-09 09:43:23 +0200
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2014-10-17 14:55:45 +0200
commit0368b24a7f53c945b582097cc8ad22a053856d22 (patch)
treebca43e19e6cab7d18f3e016b9b4ada923daf8d31 /src/corelib/io
parent1b8c5f450ba7dc3be04149020ec788a8ca03e47f (diff)
QSettings: Prevent assert when passing empty keys.
[ChangeLog][Important behavior changes][QSettings] QSettings::value() now returns an invalid QVariant when passing an empty key. The code path ran into an assert, which was only noticeable in debug builds. Task-number: QTBUG-41812 Change-Id: I5cc32be3aa267a132e9d6639ecd6cb0bbafc15b0 Reviewed-by: St├ęphane Fabry, Cutesoft <stephane.fabry@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qsettings.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index fd35ae33dc..d896da176a 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -3121,6 +3121,10 @@ bool QSettings::isWritable() const
void QSettings::setValue(const QString &key, const QVariant &value)
{
Q_D(QSettings);
+ if (key.isEmpty()) {
+ qWarning("QSettings::setValue: Empty key passed");
+ return;
+ }
QString k = d->actualKey(key);
d->set(k, value);
d->requestUpdate();
@@ -3253,6 +3257,10 @@ bool QSettings::event(QEvent *event)
QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const
{
Q_D(const QSettings);
+ if (key.isEmpty()) {
+ qWarning("QSettings::value: Empty key passed");
+ return QVariant();
+ }
QVariant result = defaultValue;
QString k = d->actualKey(key);
d->get(k, &result);