summaryrefslogtreecommitdiffstats
path: root/src/preferences.cpp
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-10-20 18:19:04 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-10-20 18:19:10 +0000
commitfe3c6f825131da03e278442d046565e4caaebb77 (patch)
tree27eb30b12ce67f2312003cfadcf262e770817602 /src/preferences.cpp
parentMerge in bootstrap5 color pallet from meetdilip (diff)
downloadinkscape-fe3c6f825131da03e278442d046565e4caaebb77.tar.gz
inkscape-fe3c6f825131da03e278442d046565e4caaebb77.zip
Preferences: hold-off on caching until fully instantiated
This avoids caching "wrong" values when setting defaults in Preferences::_loadDefaults(). (we did this since 7ca9dc4c53873955a31c1b71559da9f7b29b4a2e for OS-specific defaults) Fixes https://gitlab.com/inkscape/inkscape/issues/99
Diffstat (limited to 'src/preferences.cpp')
-rw-r--r--src/preferences.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 72a570ca2..cd4e0e461 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -66,12 +66,7 @@ private:
Glib::ustring const _filter;
};
-Preferences::Preferences() :
- _prefs_filename(""),
- _prefs_doc(nullptr),
- _errorHandler(nullptr),
- _writable(false),
- _hasError(false)
+Preferences::Preferences()
{
char *path = Inkscape::IO::Resource::profile_path(PREFERENCES_FILE_NAME);
_prefs_filename = path;
@@ -79,6 +74,8 @@ Preferences::Preferences() :
_loadDefaults();
_load();
+
+ _initialized = true;
}
Preferences::~Preferences()
@@ -720,7 +717,8 @@ void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result)
// will return empty string if `path` was not in the cache yet
auto& cacheref = cachedRawValue[path.c_str()];
- if (!cacheref.empty()) {
+ // check in cache first
+ if (_initialized && !cacheref.empty()) {
if (cacheref == RAWCACHE_CODE_NULL) {
result = nullptr;
} else {
@@ -746,11 +744,11 @@ void Preferences::_getRawValue(Glib::ustring const &path, gchar const *&result)
}
}
- if (!result) {
- cacheref = RAWCACHE_CODE_NULL;
- } else {
+ if (_initialized && result) {
cacheref = RAWCACHE_CODE_VALUE;
cacheref += result;
+ } else {
+ cacheref = RAWCACHE_CODE_NULL;
}
}
@@ -763,7 +761,10 @@ void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &v
// set the attribute
Inkscape::XML::Node *node = _getNode(node_key, true);
node->setAttribute(attr_key.c_str(), value.c_str());
- cachedRawValue[path.c_str()] = RAWCACHE_CODE_VALUE + value;
+
+ if (_initialized) {
+ cachedRawValue[path.c_str()] = RAWCACHE_CODE_VALUE + value;
+ }
}
// The _extract* methods are where the actual work is done - they define how preferences are stored