Changeset View
Changeset View
Standalone View
Standalone View
src/qt/rpcconsole.cpp
Show First 20 Lines • Show All 812 Lines • ▼ Show 20 Lines | #endif | ||||
ui->lineEdit->setEnabled(true); | ui->lineEdit->setEnabled(true); | ||||
ui->lineEdit->setCompleter(autoCompleter); | ui->lineEdit->setCompleter(autoCompleter); | ||||
autoCompleter->popup()->installEventFilter(this); | autoCompleter->popup()->installEventFilter(this); | ||||
// Start thread to execute RPC commands. | // Start thread to execute RPC commands. | ||||
startExecutor(); | startExecutor(); | ||||
} | } | ||||
if (!model) { | if (!model) { | ||||
// Client model is being set to 0, this means shutdown() is about to be | // Client model is being set to 0, this means shutdown() is about to be | ||||
// called. Make sure we clean up the executor thread | // called. | ||||
Q_EMIT stopExecutor(); | thread.quit(); | ||||
thread.wait(); | thread.wait(); | ||||
} | } | ||||
} | } | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
void RPCConsole::addWallet(WalletModel *const walletModel) { | void RPCConsole::addWallet(WalletModel *const walletModel) { | ||||
// use name for text and wallet model for internal data object (to allow to | // use name for text and wallet model for internal data object (to allow to | ||||
// move to a wallet id later) | // move to a wallet id later) | ||||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | void RPCConsole::startExecutor() { | ||||
// Replies from executor object must go to this object | // Replies from executor object must go to this object | ||||
connect(executor, &RPCExecutor::reply, this, | connect(executor, &RPCExecutor::reply, this, | ||||
static_cast<void (RPCConsole::*)(int, const QString &)>( | static_cast<void (RPCConsole::*)(int, const QString &)>( | ||||
&RPCConsole::message)); | &RPCConsole::message)); | ||||
// Requests from this object must go to executor | // Requests from this object must go to executor | ||||
connect(this, &RPCConsole::cmdRequest, executor, &RPCExecutor::request); | connect(this, &RPCConsole::cmdRequest, executor, &RPCExecutor::request); | ||||
// On stopExecutor signal | // Make sure executor object is deleted in its own thread | ||||
// - quit the Qt event loop in the execution thread | connect(&thread, &QThread::finished, executor, &RPCExecutor::deleteLater); | ||||
connect(this, &RPCConsole::stopExecutor, &thread, &QThread::quit); | |||||
// - queue executor for deletion (in execution thread) | |||||
connect(&thread, &QThread::finished, executor, &RPCExecutor::deleteLater, | |||||
Qt::DirectConnection); | |||||
// Default implementation of QThread::run() simply spins up an event loop in | // Default implementation of QThread::run() simply spins up an event loop in | ||||
// the thread, which is what we want. | // the thread, which is what we want. | ||||
thread.start(); | thread.start(); | ||||
} | } | ||||
void RPCConsole::on_tabWidget_currentChanged(int index) { | void RPCConsole::on_tabWidget_currentChanged(int index) { | ||||
if (ui->tabWidget->widget(index) == ui->tab_console) { | if (ui->tabWidget->widget(index) == ui->tab_console) { | ||||
▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines |