diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index 3d720330f4..4bc14f2f9e 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -201,7 +201,7 @@ bool Intro::pickDataDirectory(interfaces::Node& node) /* 3) Check to see if default datadir is the one we expect */ QString dataDirDefaultSettings = settings.value("strDataDirDefault").toString(); - if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || dataDirDefaultCurrent != dataDirDefaultSettings) + if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || dataDirDefaultCurrent != dataDirDefaultSettings || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false)) { /* Use selectParams here to guarantee Params() can be used by node interface */ try { @@ -240,6 +240,7 @@ bool Intro::pickDataDirectory(interfaces::Node& node) settings.setValue("strDataDir", dataDir); settings.setValue("strDataDirDefault", dataDirDefaultCurrent); + settings.setValue("fReset", false); } /* Only override -datadir if different from the default, to make it possible to * override -datadir in the dash.conf file in the default data directory diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 5509d29437..ef1a5c48b4 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include // For DEFAULT_SCRIPTCHECK_THREADS @@ -208,6 +209,9 @@ void OptionsModel::Init(bool resetSettings) if (!m_node.softSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) addOverriddenOption("-par"); + if (!settings.contains("strDataDir")) + settings.setValue("strDataDir", Intro::getDefaultDataDirectory()); + // Wallet #ifdef ENABLE_WALLET if (!settings.contains("bSpendZeroConfChange")) @@ -306,9 +310,19 @@ void OptionsModel::Reset() // Backup old settings to chain-specific datadir for troubleshooting BackupSettings(GetDataDir(true) / "guisettings.ini.bak", settings); + // Save the strDataDir setting + QString dataDir = Intro::getDefaultDataDirectory(); + dataDir = settings.value("strDataDir", dataDir).toString(); + // Remove all entries from our QSettings object settings.clear(); + // Set strDataDir + settings.setValue("strDataDir", dataDir); + + // Set that this was reset + settings.setValue("fReset", true); + // default setting for OptionsModel::StartAtStartup - disabled if (GUIUtil::GetStartOnSystemStartup()) GUIUtil::SetStartOnSystemStartup(false);