Skip to content

Commit ab73d59

Browse files
committed
Do not pass WalletModel* to queued connection
Passing a `WalletModel*` object to a queued connection when the `ENABLE_WALLET` macro is undefined make code flawed.
1 parent fdf7285 commit ab73d59

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/qt/rpcconsole.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,9 @@ void RPCConsole::on_lineEdit_returnPressed()
10321032

10331033
ui->lineEdit->clear();
10341034

1035+
WalletModel* wallet_model{nullptr};
10351036
#ifdef ENABLE_WALLET
1036-
WalletModel* wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();
1037+
wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();
10371038

10381039
if (m_last_wallet_model != wallet_model) {
10391040
if (wallet_model) {
@@ -1049,7 +1050,10 @@ void RPCConsole::on_lineEdit_returnPressed()
10491050
//: A console message indicating an entered command is currently being executed.
10501051
message(CMD_REPLY, tr("Executing…"));
10511052
m_is_executing = true;
1052-
Q_EMIT cmdRequest(cmd, m_last_wallet_model);
1053+
1054+
QMetaObject::invokeMethod(m_executor, [this, cmd, wallet_model] {
1055+
m_executor->request(cmd, wallet_model);
1056+
});
10531057

10541058
cmd = QString::fromStdString(strFilteredCmd);
10551059

@@ -1103,9 +1107,6 @@ void RPCConsole::startExecutor()
11031107
m_is_executing = false;
11041108
});
11051109

1106-
// Requests from this object must go to executor
1107-
connect(this, &RPCConsole::cmdRequest, m_executor, &RPCExecutor::request);
1108-
11091110
// Make sure executor object is deleted in its own thread
11101111
connect(&thread, &QThread::finished, m_executor, &RPCExecutor::deleteLater);
11111112

src/qt/rpcconsole.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ public Q_SLOTS:
137137
/** set which tab has the focus (is visible) */
138138
void setTabFocus(enum TabTypes tabType);
139139

140-
Q_SIGNALS:
141-
// For RPC command executor
142-
void cmdRequest(const QString &command, const WalletModel* wallet_model);
143-
144140
private:
145141
struct TranslatedStrings {
146142
const QString yes{tr("Yes")}, no{tr("No")}, to{tr("To")}, from{tr("From")},

0 commit comments

Comments
 (0)