1
0
Fork 0

Version the FG-root setting

This ensures fresh installs will see an empty value, and hence 
default to the shipped version.
This commit is contained in:
James Turner 2018-11-25 14:06:51 +00:00
parent 4956386b84
commit 1e104bbdfe
2 changed files with 10 additions and 5 deletions

View file

@ -18,9 +18,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif
#include "SetupRootDialog.hxx" #include "SetupRootDialog.hxx"
@ -42,6 +40,12 @@
#include <Include/version.h> #include <Include/version.h>
#include <Viewer/WindowBuilder.hxx> #include <Viewer/WindowBuilder.hxx>
static QString rootPathKey()
{
// return a settings key like fg-root-2018-3-0
return QString("fg-root-") + QString(FLIGHTGEAR_VERSION).replace('.', '-');
}
SetupRootDialog::SetupRootDialog(PromptState prompt) : SetupRootDialog::SetupRootDialog(PromptState prompt) :
QDialog(), QDialog(),
m_promptState(prompt) m_promptState(prompt)
@ -90,10 +94,11 @@ bool SetupRootDialog::runDialog(PromptState prompt)
return true; return true;
} }
SGPath SetupRootDialog::restoreUserSelectedRoot() SGPath SetupRootDialog::restoreUserSelectedRoot()
{ {
QSettings settings; QSettings settings;
QString path = settings.value("fg-root").toString(); QString path = settings.value(rootPathKey()).toString();
if (path == "!ask") { if (path == "!ask") {
bool ok = runDialog(ManualChoiceRequested); bool ok = runDialog(ManualChoiceRequested);
Q_ASSERT(ok); Q_ASSERT(ok);
@ -193,7 +198,7 @@ void SetupRootDialog::onBrowse()
globals->set_fg_root(m_browsedPath.toStdString()); globals->set_fg_root(m_browsedPath.toStdString());
QSettings settings; QSettings settings;
settings.setValue("fg-root", m_browsedPath); settings.setValue(rootPathKey(), m_browsedPath);
accept(); // we're done accept(); // we're done
} }

View file

@ -2918,7 +2918,7 @@ void Options::setupRoot(int argc, char **argv)
} else { } else {
// Next check if fg-root is set as an env variable // Next check if fg-root is set as an env variable
char *envp = ::getenv( "FG_ROOT" ); char *envp = ::getenv( "FG_ROOT" );
if ( envp != NULL ) { if ( envp != nullptr ) {
root = SGPath::fromLocal8Bit(envp); root = SGPath::fromLocal8Bit(envp);
SG_LOG(SG_GENERAL, SG_INFO, "set from FG_ROOT env var: fg_root = " << root ); SG_LOG(SG_GENERAL, SG_INFO, "set from FG_ROOT env var: fg_root = " << root );
} else { } else {