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.
This commit is contained in:
Russell Yanofsky 2020-07-06 10:36:15 -04:00
parent 102abff9eb
commit 519cae8fd6
3 changed files with 7 additions and 3 deletions

View file

@ -249,7 +249,6 @@ void BitcoinApplication::createPaymentServer()
void BitcoinApplication::createOptionsModel(bool resetSettings)
{
optionsModel = new OptionsModel(this, resetSettings);
optionsModel->setNode(node());
}
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
@ -264,7 +263,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();
@ -276,6 +274,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()
@ -465,7 +465,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:
@ -599,6 +598,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
{

View file

@ -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();
}

View file

@ -62,6 +62,7 @@ private:
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;