Skip to content

Commit

Permalink
qt: Do not block GUI thread in RPCConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Mar 19, 2021
1 parent 9af2549 commit 84a9a7c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
{
window = new BitcoinGUI(node(), platformStyle, networkStyle, nullptr);
connect(window, &BitcoinGUI::quitClicked, this, &BitcoinApplication::requestShutdown);
connect(window, &BitcoinGUI::rpcExecutorThreadFinished, this, &BitcoinApplication::requestNodeShutdown);

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

delete clientModel;
clientModel = nullptr;

requestNodeShutdown();
}

void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Expand Down Expand Up @@ -404,7 +403,7 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
pollShutdownTimer->start(200);
} else {
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
requestShutdown();
requestNodeShutdown();
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
updateWindowTitle();

rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
connect(rpcConsole, &RPCConsole::executorThreadFinished, this, &BitcoinGUI::rpcExecutorThreadFinished);

helpMessageDialog = new HelpMessageDialog(this, false);
#ifdef ENABLE_WALLET
if(enableWallet)
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class BitcoinGUI : public QMainWindow

Q_SIGNALS:
void quitClicked();
void rpcExecutorThreadFinished();
/** Signal raised when a URI was entered or dragged to the GUI */
void receivedURI(const QString &uri);
/** Signal raised when RPC console shown */
Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
}
if (!model) {
// Client model is being set to 0, this means shutdown() is about to be called.
connect(&thread, &QThread::finished, this, &RPCConsole::executorThreadFinished);
thread.quit();
thread.wait();
}
}

Expand Down
1 change: 1 addition & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public Q_SLOTS:
Q_SIGNALS:
// For RPC command executor
void cmdRequest(const QString &command, const WalletModel* wallet_model);
void executorThreadFinished();

private:
struct TranslatedStrings {
Expand Down

0 comments on commit 84a9a7c

Please sign in to comment.