From 0a28e951073fc5f51aa759aaa36e988b1a978475 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 4 Jan 2015 17:50:10 +0000 Subject: [PATCH] Guard against saved bad terrasync path. - warn when the terrasync path is not writeable, with a message box. --- src/Main/options.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 48efc9c50..7ba86d827 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -2225,7 +2226,7 @@ OptionResult Options::processOptions() } // terrasync directory fixup - string terrasyncDir = fgGetString("/sim/terrasync/scenery-dir"); + string terrasyncDir = simgear::strutils::strip(fgGetString("/sim/terrasync/scenery-dir")); if (terrasyncDir.empty()) { terrasyncDir = defaultTerrasyncDir(); // auto-save it for next time @@ -2249,6 +2250,17 @@ OptionResult Options::processOptions() if (!objectsDir.exists()) { objectsDir.create(0755); } + + // check the above actuall worked + if (!objectsDir.exists() || !terrainDir.exists()) { + std::stringstream ss; + ss << "Scenery download will be disabled. The configured location is '" << terrasyncDir << "'."; + flightgear::modalMessageBox("Invalid scenery download location", + "Automatic scenery download is configured to use a location (path) which invalid.", + ss.str()); + fgSetBool("/sim/terrasync/enabled", false); + } + if (fgGetBool("/sim/terrasync/enabled")) { const string_list& scenery_paths(globals->get_fg_scenery()); if (std::find(scenery_paths.begin(), scenery_paths.end(), terrasyncDir) == scenery_paths.end()) {