Skip to content

Commit ccf7902

Browse files
committed
qt, rpc, refactor: Return early in RPCConsole::on_lineEdit_returnPressed
1 parent 5b9c8c9 commit ccf7902

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

src/qt/rpcconsole.cpp

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -926,57 +926,57 @@ void RPCConsole::on_lineEdit_returnPressed()
926926
{
927927
QString cmd = ui->lineEdit->text();
928928

929-
if(!cmd.isEmpty())
930-
{
931-
std::string strFilteredCmd;
932-
try {
933-
std::string dummy;
934-
if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
935-
// Failed to parse command, so we cannot even filter it for the history
936-
throw std::runtime_error("Invalid command line");
937-
}
938-
} catch (const std::exception& e) {
939-
QMessageBox::critical(this, "Error", QString("Error: ") + QString::fromStdString(e.what()));
940-
return;
941-
}
929+
if (cmd.isEmpty()) {
930+
return;
931+
}
942932

943-
ui->lineEdit->clear();
933+
std::string strFilteredCmd;
934+
try {
935+
std::string dummy;
936+
if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
937+
// Failed to parse command, so we cannot even filter it for the history
938+
throw std::runtime_error("Invalid command line");
939+
}
940+
} catch (const std::exception& e) {
941+
QMessageBox::critical(this, "Error", QString("Error: ") + QString::fromStdString(e.what()));
942+
return;
943+
}
944944

945-
cmdBeforeBrowsing = QString();
945+
ui->lineEdit->clear();
946946

947947
#ifdef ENABLE_WALLET
948-
WalletModel* wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();
948+
WalletModel* wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();
949949

950-
if (m_last_wallet_model != wallet_model) {
951-
if (wallet_model) {
952-
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
953-
} else {
954-
message(CMD_REQUEST, tr("Executing command without any wallet"));
955-
}
956-
m_last_wallet_model = wallet_model;
950+
if (m_last_wallet_model != wallet_model) {
951+
if (wallet_model) {
952+
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
953+
} else {
954+
message(CMD_REQUEST, tr("Executing command without any wallet"));
957955
}
958-
#endif
956+
m_last_wallet_model = wallet_model;
957+
}
958+
#endif // ENABLE_WALLET
959959

960-
message(CMD_REQUEST, QString::fromStdString(strFilteredCmd));
961-
//: A console message indicating an entered command is currently being executed.
962-
message(CMD_REPLY, tr("Executing…"));
963-
Q_EMIT cmdRequest(cmd, m_last_wallet_model);
964-
965-
cmd = QString::fromStdString(strFilteredCmd);
966-
967-
// Remove command, if already in history
968-
history.removeOne(cmd);
969-
// Append command to history
970-
history.append(cmd);
971-
// Enforce maximum history size
972-
while(history.size() > CONSOLE_HISTORY)
973-
history.removeFirst();
974-
// Set pointer to end of history
975-
historyPtr = history.size();
960+
message(CMD_REQUEST, QString::fromStdString(strFilteredCmd));
961+
//: A console message indicating an entered command is currently being executed.
962+
message(CMD_REPLY, tr("Executing…"));
963+
Q_EMIT cmdRequest(cmd, m_last_wallet_model);
976964

977-
// Scroll console view to end
978-
scrollToEnd();
965+
cmd = QString::fromStdString(strFilteredCmd);
966+
967+
// Remove command, if already in history
968+
history.removeOne(cmd);
969+
// Append command to history
970+
history.append(cmd);
971+
// Enforce maximum history size
972+
while (history.size() > CONSOLE_HISTORY) {
973+
history.removeFirst();
979974
}
975+
// Set pointer to end of history
976+
historyPtr = history.size();
977+
978+
// Scroll console view to end
979+
scrollToEnd();
980980
}
981981

982982
void RPCConsole::browseHistory(int offset)

0 commit comments

Comments
 (0)