Skip to content

Commit fa6f402

Browse files
ryanofskyMarcoFalke
authored andcommitted
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.
1 parent fad2502 commit fa6f402

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/interfaces/node.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class NodeImpl : public Node
5454
{
5555
public:
5656
NodeImpl() { m_interfaces.chain = MakeChain(); }
57+
void initError(const std::string& message) override { InitError(message); }
5758
bool parseParameters(int argc, const char* const argv[], std::string& error) override
5859
{
5960
return gArgs.ParseParameters(argc, argv, error);

src/interfaces/node.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class Node
3838
public:
3939
virtual ~Node() {}
4040

41+
//! Send init error.
42+
virtual void initError(const std::string& message) = 0;
43+
4144
//! Set command line arguments.
4245
virtual bool parseParameters(int argc, const char* const argv[], std::string& error) = 0;
4346

src/qt/bitcoin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ int GuiMain(int argc, char* argv[])
456456
SetupUIArgs();
457457
std::string error;
458458
if (!node->parseParameters(argc, argv, error)) {
459-
InitError(strprintf("Error parsing command line arguments: %s\n", error));
459+
node->initError(strprintf("Error parsing command line arguments: %s\n", error));
460460
// Create a message box, because the gui has neither been created nor has subscribed to core signals
461461
QMessageBox::critical(nullptr, PACKAGE_NAME,
462462
// message can not be translated because translations have not been initialized
@@ -496,13 +496,13 @@ int GuiMain(int argc, char* argv[])
496496
/// - Do not call GetDataDir(true) before this step finishes
497497
if (!fs::is_directory(GetDataDir(false)))
498498
{
499-
InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
499+
node->initError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
500500
QMessageBox::critical(nullptr, PACKAGE_NAME,
501501
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
502502
return EXIT_FAILURE;
503503
}
504504
if (!node->readConfigFiles(error)) {
505-
InitError(strprintf("Error reading configuration file: %s\n", error));
505+
node->initError(strprintf("Error reading configuration file: %s\n", error));
506506
QMessageBox::critical(nullptr, PACKAGE_NAME,
507507
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
508508
return EXIT_FAILURE;
@@ -518,7 +518,7 @@ int GuiMain(int argc, char* argv[])
518518
try {
519519
node->selectParams(gArgs.GetChainName());
520520
} catch(std::exception &e) {
521-
InitError(strprintf("%s\n", e.what()));
521+
node->initError(strprintf("%s\n", e.what()));
522522
QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what()));
523523
return EXIT_FAILURE;
524524
}

0 commit comments

Comments
 (0)