mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
qPref: don't compare doubles for equality
This is a much safer way to do this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
617019bc6b
commit
619289074b
1 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue