From fad2502240a1c440ef03ac3f880475702e418275 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 10 Jul 2019 08:06:57 -0400 Subject: init: Use InitError for all errors in bitcoind/qt Also, remove unused include (and others) --- src/qt/bitcoin.cpp | 15 +++++++++------ src/qt/bitcoin.h | 1 - src/qt/bitcoingui.cpp | 3 --- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/qt') diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index cf0b48b545..77eb2abdbc 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include #include @@ -30,15 +30,12 @@ #include #include #include -#include #include #include #include +#include #include -#include - -#include #include #include @@ -459,8 +456,11 @@ int GuiMain(int argc, char* argv[]) SetupUIArgs(); std::string error; if (!node->parseParameters(argc, argv, error)) { + InitError(strprintf("Error parsing command line arguments: %s\n", error)); + // Create a message box, because the gui has neither been created nor has subscribed to core signals QMessageBox::critical(nullptr, PACKAGE_NAME, - QObject::tr("Error parsing command line arguments: %1.").arg(QString::fromStdString(error))); + // message can not be translated because translations have not been initialized + QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error))); return EXIT_FAILURE; } @@ -496,11 +496,13 @@ int GuiMain(int argc, char* argv[]) /// - Do not call GetDataDir(true) before this step finishes if (!fs::is_directory(GetDataDir(false))) { + InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); return EXIT_FAILURE; } if (!node->readConfigFiles(error)) { + InitError(strprintf("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; @@ -516,6 +518,7 @@ int GuiMain(int argc, char* argv[]) try { node->selectParams(gArgs.GetChainName()); } catch(std::exception &e) { + InitError(strprintf("%s\n", e.what())); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what())); return EXIT_FAILURE; } diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h index 370712d953..40537c1813 100644 --- a/src/qt/bitcoin.h +++ b/src/qt/bitcoin.h @@ -11,7 +11,6 @@ #include #include -#include class BitcoinGUI; class ClientModel; diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 266e16ebeb..6b2ce8c61d 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -36,9 +36,6 @@ #include #include -#include -#include - #include #include #include -- cgit v1.2.3 From fa6f402bde146f92ed131e0c9c8e15a55e723307 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Thu, 11 Jul 2019 18:20:44 -0400 Subject: Call node->initError instead of InitError from GUI code Avoids GUI code calling a node function, and having to live in the same process as g_ui_signals and uiInterface global variables. --- src/qt/bitcoin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qt') diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 77eb2abdbc..0ab3fd05ee 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -456,7 +456,7 @@ int GuiMain(int argc, char* argv[]) SetupUIArgs(); std::string error; if (!node->parseParameters(argc, argv, error)) { - InitError(strprintf("Error parsing command line arguments: %s\n", error)); + node->initError(strprintf("Error parsing command line arguments: %s\n", error)); // Create a message box, because the gui has neither been created nor has subscribed to core signals QMessageBox::critical(nullptr, PACKAGE_NAME, // message can not be translated because translations have not been initialized @@ -496,13 +496,13 @@ int GuiMain(int argc, char* argv[]) /// - Do not call GetDataDir(true) before this step finishes if (!fs::is_directory(GetDataDir(false))) { - InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))); + node->initError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); return EXIT_FAILURE; } if (!node->readConfigFiles(error)) { - InitError(strprintf("Error reading configuration file: %s\n", error)); + node->initError(strprintf("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; @@ -518,7 +518,7 @@ int GuiMain(int argc, char* argv[]) try { node->selectParams(gArgs.GetChainName()); } catch(std::exception &e) { - InitError(strprintf("%s\n", e.what())); + node->initError(strprintf("%s\n", e.what())); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what())); return EXIT_FAILURE; } -- cgit v1.2.3