From 32cc9be007bb75b50b588b1c28e520f8817d234b Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 20 Sep 2017 17:57:25 +0100 Subject: [PATCH] Enable auto-save migration. When performing the migration, let the user know it happened, and to be alert for any issues that might occur. --- src/GUI/CocoaHelpers.mm | 2 +- src/Main/globals.cxx | 17 ++++++++++++++--- src/Main/globals.hxx | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/GUI/CocoaHelpers.mm b/src/GUI/CocoaHelpers.mm index f93ff1edc..6c91e4906 100644 --- a/src/GUI/CocoaHelpers.mm +++ b/src/GUI/CocoaHelpers.mm @@ -72,7 +72,7 @@ flightgear::MessageBoxResult cocoaMessageBox(const std::string& msg, defaultButton:nil /* localized 'ok' */ alternateButton:nil otherButton:nil - informativeTextWithFormat:@"%@",stdStringToCocoa(text)]; + informativeTextWithFormat:@" %@",stdStringToCocoa(text)]; [[alert retain] autorelease]; [alert runModal]; return flightgear::MSG_BOX_OK; diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 4e14718d1..bda2b3dc3 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -761,7 +762,8 @@ static void tryAutosaveMigration(const SGPath& userDataPath, SGPropertyNode* pro // read migration blacklist string_list blacklist; - for (auto node : fgGetNode("/sim/autosave-migration/blacklist")->getChildren("path")) { + SGPropertyNode_ptr blacklistNode = fgGetNode("/sim/autosave-migration/blacklist", true); + for (auto node : blacklistNode->getChildren("path")) { blacklist.push_back(node->getStringValue()); } @@ -770,11 +772,20 @@ static void tryAutosaveMigration(const SGPath& userDataPath, SGPropertyNode* pro // copy remaining props out copyProperties(&oldProps, props); + + // inform the user +#if !defined(FG_TESTLIB) + flightgear::modalMessageBox("Settings migrated", + "Saved settings were migrated from a previous version of FlightGear. " + "If you encounter any problems when using the system, try restoring " + "the default settings, before reporting a problem." + "Saved settings can affect the appearance, performance and features of the simulator."); +#endif } // Load user settings from the autosave file (normally in $FG_HOME) void -FGGlobals::loadUserSettings(SGPath userDataPath, bool tryMigrate) +FGGlobals::loadUserSettings(SGPath userDataPath) { if (userDataPath.isNull()) { userDataPath = get_fg_home(); @@ -794,7 +805,7 @@ FGGlobals::loadUserSettings(SGPath userDataPath, bool tryMigrate) SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage() << "(from " << e.getOrigin() << ")"); } - } else if (tryMigrate) { + } else { tryAutosaveMigration(userDataPath, &autosave); } copyProperties(&autosave, globals->get_props()); diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 65b9a5f10..fad0fee3c 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(), bool tryMigrate = false); + void loadUserSettings(SGPath userDatapath = SGPath()); /** * Save user settings to the autosave file under 'userDataPath', which