aboutsummaryrefslogtreecommitdiffstats
path: root/subsurface-mobile-main.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-11-25 09:22:19 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-25 07:41:09 -0800
commit4fb01dd766c824529dad4bd1ca64a981e137d476 (patch)
treefe6b8e0fcea6045c048fdf8d6449af7f1acf8a4e /subsurface-mobile-main.cpp
parentcc5a56b2751de2387572eec25fde75db7b89fb6a (diff)
downloadsubsurface-4fb01dd766c824529dad4bd1ca64a981e137d476.tar.gz
Fix ownership issues in preferences code
Each preferences object owns its string members. In three cases, pointers were copied instead of strings, leading to (in the best case) dangling pointers if the user edited values: 1) In the GET_TXT macro in core/prefs-macros.h 2) In the PreferencesDialog::defaultsRequested() method 3) In main() of the mobile version This patch fixes these issues, by using copy_string() or copy_prefs() as appropriate. The only reason that the old code didn't crash regularly is that the default_prefs object was only used at startup and defaultsRequested() is (at the moment?) dead code. This patch also aligns the backslashes in core/pref.h and fixes a typo. The declaration of copy_prefs() is moved to the core/prefs.h header. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'subsurface-mobile-main.cpp')
-rw-r--r--subsurface-mobile-main.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/subsurface-mobile-main.cpp b/subsurface-mobile-main.cpp
index 0ee2890c6..63add7c50 100644
--- a/subsurface-mobile-main.cpp
+++ b/subsurface-mobile-main.cpp
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
setup_system_prefs();
if (uiLanguage(0).contains("-US"))
default_prefs.units = IMPERIAL_units;
- prefs = default_prefs;
+ copy_prefs(&default_prefs, &prefs);
fill_profile_color();
fill_computer_list();