@@ -193,10 +193,9 @@ void BitcoinCore::shutdown()
193193static int qt_argc = 1 ;
194194static const char * qt_argv = " bitcoin-qt" ;
195195
196- BitcoinApplication::BitcoinApplication (interfaces::Node& node ):
196+ BitcoinApplication::BitcoinApplication ():
197197 QApplication(qt_argc, const_cast <char **>(&qt_argv)),
198198 coreThread(nullptr ),
199- m_node(node),
200199 optionsModel(nullptr ),
201200 clientModel(nullptr ),
202201 window(nullptr ),
@@ -246,38 +245,47 @@ void BitcoinApplication::createPaymentServer()
246245
247246void BitcoinApplication::createOptionsModel (bool resetSettings)
248247{
249- optionsModel = new OptionsModel (m_node, this , resetSettings);
248+ optionsModel = new OptionsModel (this , resetSettings);
249+ optionsModel->setNode (node ());
250250}
251251
252252void BitcoinApplication::createWindow (const NetworkStyle *networkStyle)
253253{
254- window = new BitcoinGUI (m_node , platformStyle, networkStyle, nullptr );
254+ window = new BitcoinGUI (node () , platformStyle, networkStyle, nullptr );
255255
256256 pollShutdownTimer = new QTimer (window);
257257 connect (pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
258258}
259259
260260void BitcoinApplication::createSplashScreen (const NetworkStyle *networkStyle)
261261{
262- SplashScreen *splash = new SplashScreen (m_node, nullptr , networkStyle);
262+ assert (!m_splash);
263+ m_splash = new SplashScreen (nullptr , networkStyle);
264+ m_splash->setNode (node ());
263265 // We don't hold a direct pointer to the splash screen after creation, but the splash
264266 // screen will take care of deleting itself when finish() happens.
265- splash->show ();
266- connect (this , &BitcoinApplication::splashFinished, splash, &SplashScreen::finish);
267- connect (this , &BitcoinApplication::requestedShutdown, splash, &QWidget::close);
267+ m_splash->show ();
268+ connect (this , &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
269+ connect (this , &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
270+ }
271+
272+ void BitcoinApplication::setNode (interfaces::Node& node)
273+ {
274+ assert (!m_node);
275+ m_node = &node;
268276}
269277
270278bool BitcoinApplication::baseInitialize ()
271279{
272- return m_node .baseInitialize ();
280+ return node () .baseInitialize ();
273281}
274282
275283void BitcoinApplication::startThread ()
276284{
277285 if (coreThread)
278286 return ;
279287 coreThread = new QThread (this );
280- BitcoinCore *executor = new BitcoinCore (m_node );
288+ BitcoinCore *executor = new BitcoinCore (node () );
281289 executor->moveToThread (coreThread);
282290
283291 /* communication to and from thread */
@@ -331,7 +339,7 @@ void BitcoinApplication::requestShutdown()
331339 window->unsubscribeFromCoreSignals ();
332340 // Request node shutdown, which can interrupt long operations, like
333341 // rescanning a wallet.
334- m_node .startShutdown ();
342+ node () .startShutdown ();
335343 // Unsetting the client model can cause the current thread to wait for node
336344 // to complete an operation, like wait for a RPC execution to complete.
337345 window->setClientModel (nullptr );
@@ -353,7 +361,7 @@ void BitcoinApplication::initializeResult(bool success)
353361 {
354362 // Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
355363 qInfo () << " Platform customization:" << platformStyle->getName ();
356- clientModel = new ClientModel (m_node , optionsModel);
364+ clientModel = new ClientModel (node () , optionsModel);
357365 window->setClientModel (clientModel);
358366#ifdef ENABLE_WALLET
359367 if (WalletModel::isWalletEnabled ()) {
@@ -452,7 +460,8 @@ int GuiMain(int argc, char* argv[])
452460 QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
453461#endif
454462
455- BitcoinApplication app (*node);
463+ BitcoinApplication app;
464+ app.setNode (*node);
456465
457466 // / 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
458467 // Command-line options take precedence:
@@ -601,10 +610,10 @@ int GuiMain(int argc, char* argv[])
601610 }
602611 } catch (const std::exception& e) {
603612 PrintExceptionContinue (&e, " Runaway exception" );
604- app.handleRunawayException (QString::fromStdString (node-> getWarnings ().translated ));
613+ app.handleRunawayException (QString::fromStdString (app. node (). getWarnings ().translated ));
605614 } catch (...) {
606615 PrintExceptionContinue (nullptr , " Runaway exception" );
607- app.handleRunawayException (QString::fromStdString (node-> getWarnings ().translated ));
616+ app.handleRunawayException (QString::fromStdString (app. node (). getWarnings ().translated ));
608617 }
609618 return rv;
610619}
0 commit comments