diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2019-07-11 18:20:44 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-07-11 19:39:55 -0400 |
commit | fa6f402bde146f92ed131e0c9c8e15a55e723307 (patch) | |
tree | 691b18d0ea62750f169aa7def65ddadd0c3ec181 /src | |
parent | fad2502240a1c440ef03ac3f880475702e418275 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/node.cpp | 1 | ||||
-rw-r--r-- | src/interfaces/node.h | 3 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 8 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp index 584d218dba..fd2fb6531b 100644 --- a/src/interfaces/node.cpp +++ b/src/interfaces/node.cpp @@ -54,6 +54,7 @@ class NodeImpl : public Node { public: NodeImpl() { m_interfaces.chain = MakeChain(); } + void initError(const std::string& message) override { InitError(message); } bool parseParameters(int argc, const char* const argv[], std::string& error) override { return gArgs.ParseParameters(argc, argv, error); diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 1ccd2a31b7..bb4b3e1fae 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -38,6 +38,9 @@ class Node public: virtual ~Node() {} + //! Send init error. + virtual void initError(const std::string& message) = 0; + //! Set command line arguments. virtual bool parseParameters(int argc, const char* const argv[], std::string& error) = 0; 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; } |