Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 563 Lines • ▼ Show 20 Lines | #endif | ||||
/// 2. Parse command-line options. We do this after qt in order to show an | /// 2. Parse command-line options. We do this after qt in order to show an | ||||
/// error if there are problems parsing these | /// error if there are problems parsing these | ||||
// Command-line options take precedence: | // Command-line options take precedence: | ||||
node->setupServerArgs(); | node->setupServerArgs(); | ||||
SetupUIArgs(); | SetupUIArgs(); | ||||
std::string error; | std::string error; | ||||
if (!node->parseParameters(argc, argv, error)) { | if (!node->parseParameters(argc, argv, error)) { | ||||
QMessageBox::critical( | QMessageBox::critical( | ||||
nullptr, QObject::tr(PACKAGE_NAME), | nullptr, PACKAGE_NAME, | ||||
QObject::tr("Error parsing command line arguments: %1.") | QObject::tr("Error parsing command line arguments: %1.") | ||||
.arg(QString::fromStdString(error))); | .arg(QString::fromStdString(error))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
// Now that the QApplication is setup and we have parsed our parameters, we | // Now that the QApplication is setup and we have parsed our parameters, we | ||||
// can set the platform style | // can set the platform style | ||||
app.setupPlatformStyle(); | app.setupPlatformStyle(); | ||||
Show All 33 Lines | if (!Intro::pickDataDirectory(*node)) { | ||||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||||
} | } | ||||
/// 6. Determine availability of data and blocks directory and parse | /// 6. Determine availability of data and blocks directory and parse | ||||
/// bitcoin.conf | /// bitcoin.conf | ||||
/// - Do not call GetDataDir(true) before this step finishes. | /// - Do not call GetDataDir(true) before this step finishes. | ||||
if (!fs::is_directory(GetDataDir(false))) { | if (!fs::is_directory(GetDataDir(false))) { | ||||
QMessageBox::critical( | QMessageBox::critical( | ||||
nullptr, QObject::tr(PACKAGE_NAME), | nullptr, PACKAGE_NAME, | ||||
QObject::tr( | QObject::tr( | ||||
"Error: Specified data directory \"%1\" does not exist.") | "Error: Specified data directory \"%1\" does not exist.") | ||||
.arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); | .arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
if (!node->readConfigFiles(error)) { | if (!node->readConfigFiles(error)) { | ||||
QMessageBox::critical( | QMessageBox::critical( | ||||
nullptr, QObject::tr(PACKAGE_NAME), | nullptr, PACKAGE_NAME, | ||||
QObject::tr("Error: Cannot parse configuration file: %1.") | QObject::tr("Error: Cannot parse configuration file: %1.") | ||||
.arg(QString::fromStdString(error))); | .arg(QString::fromStdString(error))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
/// 7. Determine network (and switch to network specific options) | /// 7. Determine network (and switch to network specific options) | ||||
// - Do not call Params() before this step. | // - Do not call Params() before this step. | ||||
// - Do this after parsing the configuration file, as the network can be | // - Do this after parsing the configuration file, as the network can be | ||||
// switched there. | // switched there. | ||||
// - QSettings() will use the new application name after this, resulting in | // - QSettings() will use the new application name after this, resulting in | ||||
// network-specific settings. | // network-specific settings. | ||||
// - Needs to be done before createOptionsModel. | // - Needs to be done before createOptionsModel. | ||||
// Check for -testnet or -regtest parameter (Params() calls are only valid | // Check for -testnet or -regtest parameter (Params() calls are only valid | ||||
// after this clause) | // after this clause) | ||||
try { | try { | ||||
node->selectParams(gArgs.GetChainName()); | node->selectParams(gArgs.GetChainName()); | ||||
} catch (std::exception &e) { | } catch (std::exception &e) { | ||||
QMessageBox::critical(nullptr, QObject::tr(PACKAGE_NAME), | QMessageBox::critical(nullptr, PACKAGE_NAME, | ||||
QObject::tr("Error: %1").arg(e.what())); | QObject::tr("Error: %1").arg(e.what())); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
// Parse URIs on command line -- this can affect Params() | // Parse URIs on command line -- this can affect Params() | ||||
PaymentServer::ipcParseCommandLine(*node, argc, argv); | PaymentServer::ipcParseCommandLine(*node, argc, argv); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | try { | ||||
// thread won't be held up. | // thread won't be held up. | ||||
if (!app.baseInitialize(config)) { | if (!app.baseInitialize(config)) { | ||||
// A dialog with detailed error will have been shown by InitError() | // A dialog with detailed error will have been shown by InitError() | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
app.requestInitialize(config, rpcServer, httpRPCRequestProcessor); | app.requestInitialize(config, rpcServer, httpRPCRequestProcessor); | ||||
#if defined(Q_OS_WIN) | #if defined(Q_OS_WIN) | ||||
WinShutdownMonitor::registerShutdownBlockReason( | WinShutdownMonitor::registerShutdownBlockReason( | ||||
QObject::tr("%1 didn't yet exit safely...") | QObject::tr("%1 didn't yet exit safely...").arg(PACKAGE_NAME), | ||||
.arg(QObject::tr(PACKAGE_NAME)), | |||||
(HWND)app.getMainWinId()); | (HWND)app.getMainWinId()); | ||||
#endif | #endif | ||||
app.exec(); | app.exec(); | ||||
app.requestShutdown(config); | app.requestShutdown(config); | ||||
app.exec(); | app.exec(); | ||||
return app.getReturnValue(); | return app.getReturnValue(); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
PrintExceptionContinue(&e, "Runaway exception"); | PrintExceptionContinue(&e, "Runaway exception"); | ||||
Show All 10 Lines |