Skip to content

Commit 519cae8

Browse files
committed
gui: Delay interfaces::Node initialization
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.
1 parent 102abff commit 519cae8

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/qt/bitcoin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ void BitcoinApplication::createPaymentServer()
249249
void BitcoinApplication::createOptionsModel(bool resetSettings)
250250
{
251251
optionsModel = new OptionsModel(this, resetSettings);
252-
optionsModel->setNode(node());
253252
}
254253

255254
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
@@ -264,7 +263,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
264263
{
265264
assert(!m_splash);
266265
m_splash = new SplashScreen(nullptr, networkStyle);
267-
m_splash->setNode(node());
268266
// We don't hold a direct pointer to the splash screen after creation, but the splash
269267
// screen will take care of deleting itself when finish() happens.
270268
m_splash->show();
@@ -276,6 +274,8 @@ void BitcoinApplication::setNode(interfaces::Node& node)
276274
{
277275
assert(!m_node);
278276
m_node = &node;
277+
if (optionsModel) optionsModel->setNode(*m_node);
278+
if (m_splash) m_splash->setNode(*m_node);
279279
}
280280

281281
bool BitcoinApplication::baseInitialize()
@@ -465,7 +465,6 @@ int GuiMain(int argc, char* argv[])
465465
#endif
466466

467467
BitcoinApplication app;
468-
app.setNode(*node);
469468

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

601+
app.setNode(*node);
602+
602603
int rv = EXIT_SUCCESS;
603604
try
604605
{

src/qt/splashscreen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,12 @@ void SplashScreen::setNode(interfaces::Node& node)
139139
assert(!m_node);
140140
m_node = &node;
141141
subscribeToCoreSignals();
142+
if (m_shutdown) m_node->startShutdown();
142143
}
143144

144145
void SplashScreen::shutdown()
145146
{
147+
m_shutdown = true;
146148
if (m_node) m_node->startShutdown();
147149
}
148150

src/qt/splashscreen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public Q_SLOTS:
6262
int curAlignment;
6363

6464
interfaces::Node* m_node = nullptr;
65+
bool m_shutdown = false;
6566
std::unique_ptr<interfaces::Handler> m_handler_init_message;
6667
std::unique_ptr<interfaces::Handler> m_handler_show_progress;
6768
std::unique_ptr<interfaces::Handler> m_handler_load_wallet;

0 commit comments

Comments
 (0)