From cf56ef19135390af6516948246893e40720d2857 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 13 Apr 2017 13:14:53 +0100 Subject: [PATCH] Migration test runs successfully now. --- src/Main/globals.cxx | 6 ++---- src/Main/globals.hxx | 2 +- src/Main/test_autosaveMigration.cxx | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 8f7102333..4e14718d1 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -774,7 +774,7 @@ static void tryAutosaveMigration(const SGPath& userDataPath, SGPropertyNode* pro // Load user settings from the autosave file (normally in $FG_HOME) void -FGGlobals::loadUserSettings(SGPath userDataPath) +FGGlobals::loadUserSettings(SGPath userDataPath, bool tryMigrate) { if (userDataPath.isNull()) { userDataPath = get_fg_home(); @@ -794,10 +794,8 @@ FGGlobals::loadUserSettings(SGPath userDataPath) SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage() << "(from " << e.getOrigin() << ")"); } - } else { -#if 0 + } else if (tryMigrate) { tryAutosaveMigration(userDataPath, &autosave); -#endif } copyProperties(&autosave, globals->get_props()); } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index fad0fee3c..65b9a5f10 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -385,7 +385,7 @@ public: * Load user settings from the autosave file under 'userDataPath', * which defaults to $FG_HOME. */ - void loadUserSettings(SGPath userDatapath = SGPath()); + void loadUserSettings(SGPath userDatapath = SGPath(), bool tryMigrate = false); /** * Save user settings to the autosave file under 'userDataPath', which diff --git a/src/Main/test_autosaveMigration.cxx b/src/Main/test_autosaveMigration.cxx index 2e13b6f49..e4b145dae 100644 --- a/src/Main/test_autosaveMigration.cxx +++ b/src/Main/test_autosaveMigration.cxx @@ -98,7 +98,6 @@ void writeLegacyAutosave2(SGPath userData, int majorVersion, int minorVersion) of.close(); } - void testMigration() { fgtest::initTestGlobals("autosaveMigration"); @@ -141,7 +140,7 @@ void testMigration() blacklist->addChild("path")->setStringValue("/sim[0]/gui"); // execute method under test - globals->loadUserSettings(testUserDataPath); + globals->loadUserSettings(testUserDataPath, true /* try migration */); SG_CHECK_EQUAL(globals->get_props()->getNode("sim")->getChildren("presets").size(), 2); SG_CHECK_EQUAL(globals->get_props()->getNode("sim")->getChildren("gui").size(), 0);