settings: Fix defaults caching, cache key exists
authorShane Synan <digitalcircuit36939@gmail.com>
Wed, 22 Aug 2018 21:46:01 +0000 (16:46 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 28 Aug 2018 20:03:19 +0000 (22:03 +0200)
commitebbd0abc75dc8c1e9e5786e3e63d478233746dd9
treef865cefe572172ed8c9831c73dc897c2821d3ccd
parentaf6cd0ea27697a79902413da2ff898a87955ebe2
settings: Fix defaults caching, cache key exists

Add separate cache of whether or not a settings key is persisted to
disk, separate from the cache of settings key values.  Modify
localKeyExists() to make use of this cache, offering a potential
slight performance boost.

Fix caching of default values as actual settings values by always
checking if the key is persisted to disk, returning the default value
if not.

This fixes ChatMonitorSettings's "OperationMode" getting set to
"InvalidMode" by ChatMonitorFilter::_operationMode's reading of a
default "InvalidMode", then when loading settings,
ChatMonitorSettingsPage::settings["OperationMode"] would incorrectly
default to "InvalidMode" instead of "OptOut".

Test case:
1.  Start with a fresh configuration.
2.  Open Chat Monitor settings, skipping first-run wizard/etc
3.  Check that "Opt Out" is the default mode
4.  Via qDebug() prints, check that ChatMonitorFilter still sees the
    default value as InvalidMode
src/common/settings.cpp
src/common/settings.h