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 Sep 27, 2020
1 parent 2ed6cda commit 38efc5a
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 @@ -255,6 +255,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 @@ -349,8 +350,6 @@ void BitcoinApplication::requestShutdown()

delete clientModel;
clientModel = nullptr;

requestNodeShutdown();
}

void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
Expand Down Expand Up @@ -400,7 +399,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 @@ -95,6 +95,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 @@ -210,6 +210,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 @@ -690,8 +690,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 @@ -133,6 +133,7 @@ public Q_SLOTS:
Q_SIGNALS:
// For RPC command executor
void cmdRequest(const QString &command, const WalletModel* wallet_model);
void executorThreadFinished();

private:
void startExecutor();
Expand Down

0 comments on commit 38efc5a

Please sign in to comment.