diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-09-22 18:01:16 -0700 |
---|---|---|
committer | Jan Mulder <jlmulder@xs4all.nl> | 2018-09-25 15:58:17 +0200 |
commit | 619289074ba33f00bb19c5fe62c2c72782d5b997 (patch) | |
tree | eefc67618a7ad9e5d445e82cd1872cfc5b880797 | |
parent | 617019bc6b9e5bebba1cb96b1ed039befa8470ff (diff) | |
download | subsurface-619289074ba33f00bb19c5fe62c2c72782d5b997.tar.gz |
qPref: don't compare doubles for equality
This is a much safer way to do this.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/settings/qPrefPrivate.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/settings/qPrefPrivate.cpp b/core/settings/qPrefPrivate.cpp index 8cbbe932e..14fb1be1e 100644 --- a/core/settings/qPrefPrivate.cpp +++ b/core/settings/qPrefPrivate.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "qPrefPrivate.h" +#include "core/subsurface-string.h" #include <QSettings> @@ -22,7 +23,13 @@ void qPrefPrivate::propSetValue(const QString &key, const QVariant &value, const // Having it as a local variable is light weight, because it is an // interface class. QSettings s; - if (value != defaultValue) + bool isDefault = false; + if (value.isValid() && value.type() == QVariant::Double) + isDefault = IS_FP_SAME(value.toDouble(), defaultValue.toDouble()); + else + isDefault = (value == defaultValue); + + if (!isDefault) s.setValue(key, value); else s.remove(key); |