@@ -196,10 +196,9 @@ void BitcoinCore::shutdown()
196196static int qt_argc = 1 ;
197197static const char * qt_argv = " bitcoin-qt" ;
198198
199- BitcoinApplication::BitcoinApplication (interfaces::Node& node ):
199+ BitcoinApplication::BitcoinApplication ():
200200 QApplication(qt_argc, const_cast <char **>(&qt_argv)),
201201 coreThread(nullptr ),
202- m_node(node),
203202 optionsModel(nullptr ),
204203 clientModel(nullptr ),
205204 window(nullptr ),
@@ -249,38 +248,47 @@ void BitcoinApplication::createPaymentServer()
249248
250249void BitcoinApplication::createOptionsModel (bool resetSettings)
251250{
252- optionsModel = new OptionsModel (m_node, this , resetSettings);
251+ optionsModel = new OptionsModel (this , resetSettings);
252+ optionsModel->setNode (node ());
253253}
254254
255255void BitcoinApplication::createWindow (const NetworkStyle *networkStyle)
256256{
257- window = new BitcoinGUI (m_node , platformStyle, networkStyle, nullptr );
257+ window = new BitcoinGUI (node () , platformStyle, networkStyle, nullptr );
258258
259259 pollShutdownTimer = new QTimer (window);
260260 connect (pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
261261}
262262
263263void BitcoinApplication::createSplashScreen (const NetworkStyle *networkStyle)
264264{
265- SplashScreen *splash = new SplashScreen (m_node, nullptr , networkStyle);
265+ assert (!m_splash);
266+ m_splash = new SplashScreen (nullptr , networkStyle);
267+ m_splash->setNode (node ());
266268 // We don't hold a direct pointer to the splash screen after creation, but the splash
267269 // screen will take care of deleting itself when finish() happens.
268- splash->show ();
269- connect (this , &BitcoinApplication::splashFinished, splash, &SplashScreen::finish);
270- connect (this , &BitcoinApplication::requestedShutdown, splash, &QWidget::close);
270+ m_splash->show ();
271+ connect (this , &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
272+ connect (this , &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
273+ }
274+
275+ void BitcoinApplication::setNode (interfaces::Node& node)
276+ {
277+ assert (!m_node);
278+ m_node = &node;
271279}
272280
273281bool BitcoinApplication::baseInitialize ()
274282{
275- return m_node .baseInitialize ();
283+ return node () .baseInitialize ();
276284}
277285
278286void BitcoinApplication::startThread ()
279287{
280288 if (coreThread)
281289 return ;
282290 coreThread = new QThread (this );
283- BitcoinCore *executor = new BitcoinCore (m_node );
291+ BitcoinCore *executor = new BitcoinCore (node () );
284292 executor->moveToThread (coreThread);
285293
286294 /* communication to and from thread */
@@ -334,7 +342,7 @@ void BitcoinApplication::requestShutdown()
334342 window->unsubscribeFromCoreSignals ();
335343 // Request node shutdown, which can interrupt long operations, like
336344 // rescanning a wallet.
337- m_node .startShutdown ();
345+ node () .startShutdown ();
338346 // Unsetting the client model can cause the current thread to wait for node
339347 // to complete an operation, like wait for a RPC execution to complete.
340348 window->setClientModel (nullptr );
@@ -356,7 +364,7 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
356364 {
357365 // Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
358366 qInfo () << " Platform customization:" << platformStyle->getName ();
359- clientModel = new ClientModel (m_node , optionsModel);
367+ clientModel = new ClientModel (node () , optionsModel);
360368 window->setClientModel (clientModel, &tip_info);
361369#ifdef ENABLE_WALLET
362370 if (WalletModel::isWalletEnabled ()) {
@@ -456,7 +464,8 @@ int GuiMain(int argc, char* argv[])
456464 QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
457465#endif
458466
459- BitcoinApplication app (*node);
467+ BitcoinApplication app;
468+ app.setNode (*node);
460469
461470 // / 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
462471 // Command-line options take precedence:
@@ -612,10 +621,10 @@ int GuiMain(int argc, char* argv[])
612621 }
613622 } catch (const std::exception& e) {
614623 PrintExceptionContinue (&e, " Runaway exception" );
615- app.handleRunawayException (QString::fromStdString (node-> getWarnings ().translated ));
624+ app.handleRunawayException (QString::fromStdString (app. node (). getWarnings ().translated ));
616625 } catch (...) {
617626 PrintExceptionContinue (nullptr , " Runaway exception" );
618- app.handleRunawayException (QString::fromStdString (node-> getWarnings ().translated ));
627+ app.handleRunawayException (QString::fromStdString (app. node (). getWarnings ().translated ));
619628 }
620629 return rv;
621630}
0 commit comments