Skip to content

Commit fd6d499

Browse files
committed
gui: Fix m_node.startShutdown() order
This change forwards the shutdown request on the GUI (close the application for instace) to the node as soon as possible. This way the GUI doesn't have to wait for long operations to complete (rescan the wallet for instance), instead those operations detect the shutdown request and abort/interrupt.
1 parent 07b9aad commit fd6d499

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/qt/bitcoin.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,20 @@ void BitcoinApplication::requestShutdown()
309309
qDebug() << __func__ << ": Requesting shutdown";
310310
startThread();
311311
window->hide();
312+
// Must disconnect node signals otherwise current thread can deadlock since
313+
// no event loop is running.
314+
window->unsubscribeFromCoreSignals();
315+
// Request node shutdown, which can interrupt long operations, like
316+
// rescanning a wallet.
317+
m_node.startShutdown();
318+
// Unsetting the client model can cause the current thread to wait for node
319+
// to complete an operation, like wait for a RPC execution to complate.
312320
window->setClientModel(nullptr);
313321
pollShutdownTimer->stop();
314322

315323
delete clientModel;
316324
clientModel = nullptr;
317325

318-
m_node.startShutdown();
319-
320326
// Request shutdown from core thread
321327
Q_EMIT requestedShutdown();
322328
}

0 commit comments

Comments
 (0)