Merge #8487: Persist the datadir after option reset

57acb82 Load choose datadir dialog after options reset (Andrew Chow)
15df3c1 Persist the datadir after option reset (Andrew Chow)
This commit is contained in:
Jonas Schnelli 2016-08-25 11:42:45 +02:00 committed by Munkybooty
parent 3856ce485e
commit e12e018dcf
2 changed files with 16 additions and 1 deletions

View File

@ -201,7 +201,7 @@ bool Intro::pickDataDirectory(interfaces::Node& node)
/* 3) Check to see if default datadir is the one we expect */ /* 3) Check to see if default datadir is the one we expect */
QString dataDirDefaultSettings = settings.value("strDataDirDefault").toString(); 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 */ /* Use selectParams here to guarantee Params() can be used by node interface */
try { try {
@ -240,6 +240,7 @@ bool Intro::pickDataDirectory(interfaces::Node& node)
settings.setValue("strDataDir", dataDir); settings.setValue("strDataDir", dataDir);
settings.setValue("strDataDirDefault", dataDirDefaultCurrent); settings.setValue("strDataDirDefault", dataDirDefaultCurrent);
settings.setValue("fReset", false);
} }
/* Only override -datadir if different from the default, to make it possible to /* 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 * override -datadir in the dash.conf file in the default data directory

View File

@ -12,6 +12,7 @@
#include <qt/bitcoinunits.h> #include <qt/bitcoinunits.h>
#include <qt/guiconstants.h> #include <qt/guiconstants.h>
#include <qt/guiutil.h> #include <qt/guiutil.h>
#include <qt/intro.h>
#include <interfaces/node.h> #include <interfaces/node.h>
#include <validation.h> // For DEFAULT_SCRIPTCHECK_THREADS #include <validation.h> // For DEFAULT_SCRIPTCHECK_THREADS
@ -208,6 +209,9 @@ void OptionsModel::Init(bool resetSettings)
if (!m_node.softSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) if (!m_node.softSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
addOverriddenOption("-par"); addOverriddenOption("-par");
if (!settings.contains("strDataDir"))
settings.setValue("strDataDir", Intro::getDefaultDataDirectory());
// Wallet // Wallet
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (!settings.contains("bSpendZeroConfChange")) if (!settings.contains("bSpendZeroConfChange"))
@ -306,9 +310,19 @@ void OptionsModel::Reset()
// Backup old settings to chain-specific datadir for troubleshooting // Backup old settings to chain-specific datadir for troubleshooting
BackupSettings(GetDataDir(true) / "guisettings.ini.bak", settings); 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 // Remove all entries from our QSettings object
settings.clear(); settings.clear();
// Set strDataDir
settings.setValue("strDataDir", dataDir);
// Set that this was reset
settings.setValue("fReset", true);
// default setting for OptionsModel::StartAtStartup - disabled // default setting for OptionsModel::StartAtStartup - disabled
if (GUIUtil::GetStartOnSystemStartup()) if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(false); GUIUtil::SetStartOnSystemStartup(false);