Skip to content

Commit 84a9a7c

Browse files
committed
qt: Do not block GUI thread in RPCConsole
1 parent 9af2549 commit 84a9a7c

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

src/qt/bitcoin.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
258258
{
259259
window = new BitcoinGUI(node(), platformStyle, networkStyle, nullptr);
260260
connect(window, &BitcoinGUI::quitClicked, this, &BitcoinApplication::requestShutdown);
261+
connect(window, &BitcoinGUI::rpcExecutorThreadFinished, this, &BitcoinApplication::requestNodeShutdown);
261262

262263
pollShutdownTimer = new QTimer(window);
263264
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
@@ -353,8 +354,6 @@ void BitcoinApplication::requestShutdown()
353354

354355
delete clientModel;
355356
clientModel = nullptr;
356-
357-
requestNodeShutdown();
358357
}
359358

360359
void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
@@ -404,7 +403,7 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
404403
pollShutdownTimer->start(200);
405404
} else {
406405
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
407-
requestShutdown();
406+
requestNodeShutdown();
408407
}
409408
}
410409

src/qt/bitcoingui.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
9898
updateWindowTitle();
9999

100100
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
101+
connect(rpcConsole, &RPCConsole::executorThreadFinished, this, &BitcoinGUI::rpcExecutorThreadFinished);
102+
101103
helpMessageDialog = new HelpMessageDialog(this, false);
102104
#ifdef ENABLE_WALLET
103105
if(enableWallet)

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class BitcoinGUI : public QMainWindow
212212

213213
Q_SIGNALS:
214214
void quitClicked();
215+
void rpcExecutorThreadFinished();
215216
/** Signal raised when a URI was entered or dragged to the GUI */
216217
void receivedURI(const QString &uri);
217218
/** Signal raised when RPC console shown */

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
707707
}
708708
if (!model) {
709709
// Client model is being set to 0, this means shutdown() is about to be called.
710+
connect(&thread, &QThread::finished, this, &RPCConsole::executorThreadFinished);
710711
thread.quit();
711-
thread.wait();
712712
}
713713
}
714714

src/qt/rpcconsole.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public Q_SLOTS:
134134
Q_SIGNALS:
135135
// For RPC command executor
136136
void cmdRequest(const QString &command, const WalletModel* wallet_model);
137+
void executorThreadFinished();
137138

138139
private:
139140
struct TranslatedStrings {

0 commit comments

Comments
 (0)