|
27 | 27 | #include <QScreen> |
28 | 28 |
|
29 | 29 |
|
30 | | -SplashScreen::SplashScreen(const NetworkStyle* networkStyle) |
31 | | - : QWidget(), curAlignment(0) |
| 30 | +SplashScreen::SplashScreen(interfaces::Node& node, const NetworkStyle* networkStyle) |
| 31 | + : QWidget(), curAlignment(0), m_node{node} |
32 | 32 | { |
33 | 33 | // set reference point, paddings |
34 | 34 | int paddingRight = 50; |
@@ -130,25 +130,19 @@ SplashScreen::SplashScreen(const NetworkStyle* networkStyle) |
130 | 130 | installEventFilter(this); |
131 | 131 |
|
132 | 132 | GUIUtil::handleCloseWindowShortcut(this); |
133 | | -} |
134 | 133 |
|
135 | | -SplashScreen::~SplashScreen() |
136 | | -{ |
137 | | - if (m_node) unsubscribeFromCoreSignals(); |
| 134 | + subscribeToCoreSignals(); |
138 | 135 | } |
139 | 136 |
|
140 | | -void SplashScreen::setNode(interfaces::Node& node) |
| 137 | +SplashScreen::~SplashScreen() |
141 | 138 | { |
142 | | - assert(!m_node); |
143 | | - m_node = &node; |
144 | | - subscribeToCoreSignals(); |
145 | | - if (m_shutdown) m_node->startShutdown(); |
| 139 | + unsubscribeFromCoreSignals(); |
146 | 140 | } |
147 | 141 |
|
148 | 142 | void SplashScreen::shutdown() |
149 | 143 | { |
150 | 144 | m_shutdown = true; |
151 | | - if (m_node) m_node->startShutdown(); |
| 145 | + m_node.startShutdown(); |
152 | 146 | } |
153 | 147 |
|
154 | 148 | bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) { |
@@ -192,16 +186,16 @@ static void ShowProgress(SplashScreen *splash, const std::string &title, int nPr |
192 | 186 | void SplashScreen::subscribeToCoreSignals() |
193 | 187 | { |
194 | 188 | // Connect signals to client |
195 | | - m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1)); |
196 | | - m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
197 | | - m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); }); |
| 189 | + m_handler_init_message = m_node.handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1)); |
| 190 | + m_handler_show_progress = m_node.handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
| 191 | + m_handler_init_wallet = m_node.handleInitWallet([this]() { handleLoadWallet(); }); |
198 | 192 | } |
199 | 193 |
|
200 | 194 | void SplashScreen::handleLoadWallet() |
201 | 195 | { |
202 | 196 | #ifdef ENABLE_WALLET |
203 | 197 | if (!WalletModel::isWalletEnabled()) return; |
204 | | - m_handler_load_wallet = m_node->walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) { |
| 198 | + m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) { |
205 | 199 | m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false))); |
206 | 200 | m_connected_wallets.emplace_back(std::move(wallet)); |
207 | 201 | }); |
|
0 commit comments