mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-27 09:21:43 +02:00
gui: bugfix, catch invalid networks combination crash
We shouldn't crash if a network is set inside bitcoin.conf and another one is provided as param.
This commit is contained in:
parent
e9262ea32a
commit
f4a11d7baf
@ -592,29 +592,30 @@ int GuiMain(int argc, char* argv[])
|
|||||||
// Gracefully exit if the user cancels
|
// Gracefully exit if the user cancels
|
||||||
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;
|
if (!Intro::showIfNeeded(did_show_intro, prune_MiB)) return EXIT_SUCCESS;
|
||||||
|
|
||||||
/// 6. Determine availability of data directory and parse bitcoin.conf
|
/// 6a. Determine availability of data directory
|
||||||
/// - Do not call gArgs.GetDataDirNet() before this step finishes
|
|
||||||
if (!CheckDataDirOption()) {
|
if (!CheckDataDirOption()) {
|
||||||
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
|
InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", "")));
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
||||||
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
|
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (!gArgs.ReadConfigFiles(error, true)) {
|
|
||||||
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
|
|
||||||
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
|
||||||
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 7. Determine network (and switch to network specific options)
|
|
||||||
// - Do not call Params() before this step
|
|
||||||
// - Do this after parsing the configuration file, as the network can be switched there
|
|
||||||
// - QSettings() will use the new application name after this, resulting in network-specific settings
|
|
||||||
// - Needs to be done before createOptionsModel
|
|
||||||
|
|
||||||
// Check for chain settings (Params() calls are only valid after this clause)
|
|
||||||
try {
|
try {
|
||||||
|
/// 6b. Parse bitcoin.conf
|
||||||
|
/// - Do not call gArgs.GetDataDirNet() before this step finishes
|
||||||
|
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||||
|
InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error));
|
||||||
|
QMessageBox::critical(nullptr, PACKAGE_NAME,
|
||||||
|
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 7. Determine network (and switch to network specific options)
|
||||||
|
// - Do not call Params() before this step
|
||||||
|
// - Do this after parsing the configuration file, as the network can be switched there
|
||||||
|
// - QSettings() will use the new application name after this, resulting in network-specific settings
|
||||||
|
// - Needs to be done before createOptionsModel
|
||||||
|
|
||||||
|
// Check for chain settings (Params() calls are only valid after this clause)
|
||||||
SelectParams(gArgs.GetChainName());
|
SelectParams(gArgs.GetChainName());
|
||||||
} catch(std::exception &e) {
|
} catch(std::exception &e) {
|
||||||
InitError(Untranslated(strprintf("%s\n", e.what())));
|
InitError(Untranslated(strprintf("%s\n", e.what())));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user