diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2020-07-06 10:36:15 -0400 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2020-08-26 05:52:31 -0400 |
commit | 519cae8fd6e44aef3470415d7c5e12acb0acd9f4 (patch) | |
tree | 8c76ab65ae45db775f989f4269fbba7ee2e0fad4 /src | |
parent | 102abff9eb6c267af64f2a3560712147d1896e13 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/bitcoin.cpp | 7 | ||||
-rw-r--r-- | src/qt/splashscreen.cpp | 2 | ||||
-rw-r--r-- | src/qt/splashscreen.h | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 01799f34df..e63ffdfb36 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -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 { diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 50fe8eb28b..bd63d6e7fb 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -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(); } diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index dc394ac439..2213b02c55 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -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; |