mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-06 21:20:57 +02:00
qt, rpc, refactor: Return early in RPCConsole::on_lineEdit_returnPressed
This commit is contained in:
parent
5b9c8c9cdd
commit
ccf790287c
@ -926,57 +926,57 @@ void RPCConsole::on_lineEdit_returnPressed()
|
|||||||
{
|
{
|
||||||
QString cmd = ui->lineEdit->text();
|
QString cmd = ui->lineEdit->text();
|
||||||
|
|
||||||
if(!cmd.isEmpty())
|
if (cmd.isEmpty()) {
|
||||||
{
|
return;
|
||||||
std::string strFilteredCmd;
|
}
|
||||||
try {
|
|
||||||
std::string dummy;
|
std::string strFilteredCmd;
|
||||||
if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
|
try {
|
||||||
// Failed to parse command, so we cannot even filter it for the history
|
std::string dummy;
|
||||||
throw std::runtime_error("Invalid command line");
|
if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
|
||||||
}
|
// Failed to parse command, so we cannot even filter it for the history
|
||||||
} catch (const std::exception& e) {
|
throw std::runtime_error("Invalid command line");
|
||||||
QMessageBox::critical(this, "Error", QString("Error: ") + QString::fromStdString(e.what()));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
QMessageBox::critical(this, "Error", QString("Error: ") + QString::fromStdString(e.what()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ui->lineEdit->clear();
|
ui->lineEdit->clear();
|
||||||
|
|
||||||
cmdBeforeBrowsing = QString();
|
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
WalletModel* wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();
|
WalletModel* wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();
|
||||||
|
|
||||||
if (m_last_wallet_model != wallet_model) {
|
if (m_last_wallet_model != wallet_model) {
|
||||||
if (wallet_model) {
|
if (wallet_model) {
|
||||||
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
|
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
|
||||||
} else {
|
} else {
|
||||||
message(CMD_REQUEST, tr("Executing command without any wallet"));
|
message(CMD_REQUEST, tr("Executing command without any wallet"));
|
||||||
}
|
|
||||||
m_last_wallet_model = wallet_model;
|
|
||||||
}
|
}
|
||||||
#endif
|
m_last_wallet_model = wallet_model;
|
||||||
|
|
||||||
message(CMD_REQUEST, QString::fromStdString(strFilteredCmd));
|
|
||||||
//: A console message indicating an entered command is currently being executed.
|
|
||||||
message(CMD_REPLY, tr("Executing…"));
|
|
||||||
Q_EMIT cmdRequest(cmd, m_last_wallet_model);
|
|
||||||
|
|
||||||
cmd = QString::fromStdString(strFilteredCmd);
|
|
||||||
|
|
||||||
// Remove command, if already in history
|
|
||||||
history.removeOne(cmd);
|
|
||||||
// Append command to history
|
|
||||||
history.append(cmd);
|
|
||||||
// Enforce maximum history size
|
|
||||||
while(history.size() > CONSOLE_HISTORY)
|
|
||||||
history.removeFirst();
|
|
||||||
// Set pointer to end of history
|
|
||||||
historyPtr = history.size();
|
|
||||||
|
|
||||||
// Scroll console view to end
|
|
||||||
scrollToEnd();
|
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
|
message(CMD_REQUEST, QString::fromStdString(strFilteredCmd));
|
||||||
|
//: A console message indicating an entered command is currently being executed.
|
||||||
|
message(CMD_REPLY, tr("Executing…"));
|
||||||
|
Q_EMIT cmdRequest(cmd, m_last_wallet_model);
|
||||||
|
|
||||||
|
cmd = QString::fromStdString(strFilteredCmd);
|
||||||
|
|
||||||
|
// Remove command, if already in history
|
||||||
|
history.removeOne(cmd);
|
||||||
|
// Append command to history
|
||||||
|
history.append(cmd);
|
||||||
|
// Enforce maximum history size
|
||||||
|
while (history.size() > CONSOLE_HISTORY) {
|
||||||
|
history.removeFirst();
|
||||||
|
}
|
||||||
|
// Set pointer to end of history
|
||||||
|
historyPtr = history.size();
|
||||||
|
|
||||||
|
// Scroll console view to end
|
||||||
|
scrollToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCConsole::browseHistory(int offset)
|
void RPCConsole::browseHistory(int offset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user