aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-03-20 04:59:14 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-31 23:32:59 +0300
commitccf790287c53edbc7b18983e07f520823436c003 (patch)
tree5b3ade1bde4fb2c7531e3ba7cfe9e786c69ec039 /src
parent5b9c8c9cdd8e12d2e477840df9d6ab809a613c12 (diff)
qt, rpc, refactor: Return early in RPCConsole::on_lineEdit_returnPressed
Diffstat (limited to 'src')
-rw-r--r--src/qt/rpcconsole.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index b5d639e46c..1384c8e35a 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -926,57 +926,57 @@ void RPCConsole::on_lineEdit_returnPressed()
{
QString cmd = ui->lineEdit->text();
- if(!cmd.isEmpty())
- {
- std::string strFilteredCmd;
- try {
- std::string dummy;
- if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
- // Failed to parse command, so we cannot even filter it for the history
- throw std::runtime_error("Invalid command line");
- }
- } catch (const std::exception& e) {
- QMessageBox::critical(this, "Error", QString("Error: ") + QString::fromStdString(e.what()));
- return;
- }
+ if (cmd.isEmpty()) {
+ return;
+ }
- ui->lineEdit->clear();
+ std::string strFilteredCmd;
+ try {
+ std::string dummy;
+ if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
+ // Failed to parse command, so we cannot even filter it for the history
+ throw std::runtime_error("Invalid command line");
+ }
+ } catch (const std::exception& e) {
+ QMessageBox::critical(this, "Error", QString("Error: ") + QString::fromStdString(e.what()));
+ return;
+ }
- cmdBeforeBrowsing = QString();
+ ui->lineEdit->clear();
#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 (wallet_model) {
- message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
- } else {
- message(CMD_REQUEST, tr("Executing command without any wallet"));
- }
- m_last_wallet_model = wallet_model;
+ if (m_last_wallet_model != wallet_model) {
+ if (wallet_model) {
+ message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
+ } else {
+ message(CMD_REQUEST, tr("Executing command without any wallet"));
}
-#endif
+ m_last_wallet_model = wallet_model;
+ }
+#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();
+ 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);
- // Scroll console view to end
- scrollToEnd();
+ 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)