Skip to content

Commit

Permalink
gui: Delay interfaces::Node initialization
Browse files Browse the repository at this point in the history
This is needed to allow bitcoin-gui to connect to existing node process with
-ipcconnect instead of spawning a new process. It's possible to spawn a new
bitcoin-node process without knowing the current data dir or network, but
connecting to an existing bitcoin-node requires knowing the datadir and network
first.
  • Loading branch information
ryanofsky committed Jul 30, 2020
1 parent 8d3cefa commit 1a0875f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ void BitcoinApplication::createPaymentServer()
void BitcoinApplication::createOptionsModel(bool resetSettings)
{
optionsModel = new OptionsModel(this, resetSettings);
optionsModel->setNode(node());
}

void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
Expand All @@ -261,7 +260,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
{
assert(!m_splash);
m_splash = new SplashScreen(nullptr, networkStyle);
m_splash->setNode(node());
// We don't hold a direct pointer to the splash screen after creation, but the splash
// screen will take care of deleting itself when finish() happens.
m_splash->show();
Expand All @@ -273,6 +271,8 @@ void BitcoinApplication::setNode(interfaces::Node& node)
{
assert(!m_node);
m_node = &node;
if (optionsModel) optionsModel->setNode(*m_node);
if (m_splash) m_splash->setNode(*m_node);
}

bool BitcoinApplication::baseInitialize()
Expand Down Expand Up @@ -461,7 +461,6 @@ int GuiMain(int argc, char* argv[])
#endif

BitcoinApplication app;
app.setNode(*node);

/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
// Command-line options take precedence:
Expand Down Expand Up @@ -595,6 +594,8 @@ int GuiMain(int argc, char* argv[])
if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
app.createSplashScreen(networkStyle.data());

app.setNode(*node);

int rv = EXIT_SUCCESS;
try
{
Expand Down
2 changes: 2 additions & 0 deletions src/qt/splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ void SplashScreen::setNode(interfaces::Node& node)
assert(!m_node);
m_node = &node;
subscribeToCoreSignals();
if (m_shutdown) m_node->startShutdown();
}

void SplashScreen::shutdown()
{
m_shutdown = true;
if (m_node) m_node->startShutdown();
}

Expand Down
1 change: 1 addition & 0 deletions src/qt/splashscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Q_SLOTS:
int curAlignment;

interfaces::Node* m_node = nullptr;
bool m_shutdown = false;
std::unique_ptr<interfaces::Handler> m_handler_init_message;
std::unique_ptr<interfaces::Handler> m_handler_show_progress;
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
Expand Down

0 comments on commit 1a0875f

Please sign in to comment.