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:
parent
4956386b84
commit
1e104bbdfe
2 changed files with 10 additions and 5 deletions
|
@ -18,9 +18,7 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "SetupRootDialog.hxx"
|
||||
|
||||
|
@ -42,6 +40,12 @@
|
|||
#include <Include/version.h>
|
||||
#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) :
|
||||
QDialog(),
|
||||
m_promptState(prompt)
|
||||
|
@ -90,10 +94,11 @@ bool SetupRootDialog::runDialog(PromptState prompt)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGPath SetupRootDialog::restoreUserSelectedRoot()
|
||||
{
|
||||
QSettings settings;
|
||||
QString path = settings.value("fg-root").toString();
|
||||
QString path = settings.value(rootPathKey()).toString();
|
||||
if (path == "!ask") {
|
||||
bool ok = runDialog(ManualChoiceRequested);
|
||||
Q_ASSERT(ok);
|
||||
|
@ -193,7 +198,7 @@ void SetupRootDialog::onBrowse()
|
|||
globals->set_fg_root(m_browsedPath.toStdString());
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("fg-root", m_browsedPath);
|
||||
settings.setValue(rootPathKey(), m_browsedPath);
|
||||
|
||||
accept(); // we're done
|
||||
}
|
||||
|
|
|
@ -2918,7 +2918,7 @@ void Options::setupRoot(int argc, char **argv)
|
|||
} else {
|
||||
// Next check if fg-root is set as an env variable
|
||||
char *envp = ::getenv( "FG_ROOT" );
|
||||
if ( envp != NULL ) {
|
||||
if ( envp != nullptr ) {
|
||||
root = SGPath::fromLocal8Bit(envp);
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "set from FG_ROOT env var: fg_root = " << root );
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue