diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-10-06 10:15:38 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-10-06 10:19:43 +0100 |
commit | 9d8b0addf94c86f224093bb1ca66ebe18494ff7c (patch) | |
tree | 6d6b07d5dfabf73e3c58847af2b15b3754a9a357 /qt-ui | |
parent | c75ec7a04ab14c906c3e58febf142ffb8f73b8bc (diff) | |
download | subsurface-9d8b0addf94c86f224093bb1ca66ebe18494ff7c.tar.gz |
Correctly copy preferences
When just assigning one structure to the other we copy the string
pointers. If we then modify those strings in the copy, we happily free
the strings of the original. And then resetting the preferences equally
happily reused those strings, pointing to long since freed memory.
I think what I did now is excessive for the current use case in that it
copies a ton of strings that are unset in the default_prefs. But I figured
this is a rarely used function and I might as well do it correctly.
Also, once we implement multi user support with per user preferences we
will be copying completely populated preferences around (at least that's
my guess).
Fixes #940
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/preferences.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 32f05c4ab..715745e84 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -4,6 +4,7 @@ #include "divelocationmodel.h" #include "prefs-macros.h" #include "qthelper.h" +#include "subsurfacestartup.h" #include <QSettings> #include <QFileDialog> @@ -494,7 +495,7 @@ void PreferencesDialog::on_resetSettings_clicked() int result = response.exec(); if (result == QMessageBox::Ok) { - prefs = default_prefs; + copy_prefs(&default_prefs, &prefs); setUiFromPrefs(); Q_FOREACH (QString key, s.allKeys()) { s.remove(key); |