Merge #15280: gui: Fix shutdown order
0dd6a8c124
Check m_internals in UnregisterValidationInterface (João Barbosa)fd6d499bda
gui: Fix m_node.startShutdown() order (João Barbosa)07b9aadcfc
gui: Expose BitcoinGUI::unsubscribeFromCoreSignals (João Barbosa)60e190ceb3
gui: Fix WalletController deletion (João Barbosa) Pull request description: This PR consists in small fixes in order to have a clean shutdown from the GUI. Tree-SHA512: a9c641f202bc810698c4a39d5c5a1f54e54bdab098c412d65418879e00764a9db9f38383813914d591e24e097e49f177942b2ae6c57bba05dcc095e8a1d0b8f4
This commit is contained in:
commit
64127b3098
3 changed files with 16 additions and 9 deletions
|
@ -218,6 +218,8 @@ BitcoinApplication::~BitcoinApplication()
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
delete paymentServer;
|
delete paymentServer;
|
||||||
paymentServer = nullptr;
|
paymentServer = nullptr;
|
||||||
|
delete m_wallet_controller;
|
||||||
|
m_wallet_controller = nullptr;
|
||||||
#endif
|
#endif
|
||||||
delete optionsModel;
|
delete optionsModel;
|
||||||
optionsModel = nullptr;
|
optionsModel = nullptr;
|
||||||
|
@ -307,18 +309,20 @@ void BitcoinApplication::requestShutdown()
|
||||||
qDebug() << __func__ << ": Requesting shutdown";
|
qDebug() << __func__ << ": Requesting shutdown";
|
||||||
startThread();
|
startThread();
|
||||||
window->hide();
|
window->hide();
|
||||||
|
// Must disconnect node signals otherwise current thread can deadlock since
|
||||||
|
// no event loop is running.
|
||||||
|
window->unsubscribeFromCoreSignals();
|
||||||
|
// Request node shutdown, which can interrupt long operations, like
|
||||||
|
// rescanning a wallet.
|
||||||
|
m_node.startShutdown();
|
||||||
|
// Unsetting the client model can cause the current thread to wait for node
|
||||||
|
// to complete an operation, like wait for a RPC execution to complate.
|
||||||
window->setClientModel(nullptr);
|
window->setClientModel(nullptr);
|
||||||
pollShutdownTimer->stop();
|
pollShutdownTimer->stop();
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
|
||||||
delete m_wallet_controller;
|
|
||||||
m_wallet_controller = nullptr;
|
|
||||||
#endif
|
|
||||||
delete clientModel;
|
delete clientModel;
|
||||||
clientModel = nullptr;
|
clientModel = nullptr;
|
||||||
|
|
||||||
m_node.startShutdown();
|
|
||||||
|
|
||||||
// Request shutdown from core thread
|
// Request shutdown from core thread
|
||||||
Q_EMIT requestedShutdown();
|
Q_EMIT requestedShutdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,9 @@ public:
|
||||||
*/
|
*/
|
||||||
bool hasTrayIcon() const { return trayIcon; }
|
bool hasTrayIcon() const { return trayIcon; }
|
||||||
|
|
||||||
|
/** Disconnect core signals from GUI client */
|
||||||
|
void unsubscribeFromCoreSignals();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
@ -184,8 +187,6 @@ private:
|
||||||
|
|
||||||
/** Connect core signals to GUI client */
|
/** Connect core signals to GUI client */
|
||||||
void subscribeToCoreSignals();
|
void subscribeToCoreSignals();
|
||||||
/** Disconnect core signals from GUI client */
|
|
||||||
void unsubscribeFromCoreSignals();
|
|
||||||
|
|
||||||
/** Update UI with latest network info from model. */
|
/** Update UI with latest network info from model. */
|
||||||
void updateNetworkState();
|
void updateNetworkState();
|
||||||
|
|
|
@ -107,7 +107,9 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
void UnregisterValidationInterface(CValidationInterface* pwalletIn) {
|
||||||
g_signals.m_internals->m_connMainSignals.erase(pwalletIn);
|
if (g_signals.m_internals) {
|
||||||
|
g_signals.m_internals->m_connMainSignals.erase(pwalletIn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterAllValidationInterfaces() {
|
void UnregisterAllValidationInterfaces() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue