Skip to content

Commit 47912c5

Browse files
committed
qt: Do not block GUI thread in RPCConsole
1 parent 9495d26 commit 47912c5

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
@@ -253,6 +253,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
253253
{
254254
window = new BitcoinGUI(m_node, platformStyle, networkStyle, nullptr);
255255
connect(window, &BitcoinGUI::quitClicked, this, &BitcoinApplication::requestShutdown);
256+
connect(window, &BitcoinGUI::rpcExecutorThreadFinished, this, &BitcoinApplication::requestNodeShutdown);
256257

257258
pollShutdownTimer = new QTimer(window);
258259
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
@@ -338,8 +339,6 @@ void BitcoinApplication::requestShutdown()
338339

339340
delete clientModel;
340341
clientModel = nullptr;
341-
342-
requestNodeShutdown();
343342
}
344343

345344
void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
@@ -389,7 +388,7 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
389388
pollShutdownTimer->start(200);
390389
} else {
391390
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
392-
requestShutdown();
391+
requestNodeShutdown();
393392
}
394393
}
395394

src/qt/bitcoingui.cpp

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

9797
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
98+
connect(rpcConsole, &RPCConsole::executorThreadFinished, this, &BitcoinGUI::rpcExecutorThreadFinished);
99+
98100
helpMessageDialog = new HelpMessageDialog(node, this, false);
99101
#ifdef ENABLE_WALLET
100102
if(enableWallet)

src/qt/bitcoingui.h

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

211211
Q_SIGNALS:
212212
void quitClicked();
213+
void rpcExecutorThreadFinished();
213214
/** Signal raised when a URI was entered or dragged to the GUI */
214215
void receivedURI(const QString &uri);
215216
/** Signal raised when RPC console shown */

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
690690
}
691691
if (!model) {
692692
// Client model is being set to 0, this means shutdown() is about to be called.
693+
connect(&thread, &QThread::finished, this, &RPCConsole::executorThreadFinished);
693694
thread.quit();
694-
thread.wait();
695695
}
696696
}
697697

src/qt/rpcconsole.h

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

137138
private:
138139
void startExecutor();

0 commit comments

Comments
 (0)