diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-04-21 00:39:46 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-04-21 14:04:56 +0200 |
commit | ab73d5985de5d9c4d1e3fd0f4d9d88a0908ea319 (patch) | |
tree | 0b4c4f788d5013c17190aa4e62073803a5b0966e /src | |
parent | fdf72859504d063d0a6b60a6dac5ad170bd86440 (diff) | |
download | bitcoin-ab73d5985de5d9c4d1e3fd0f4d9d88a0908ea319.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/rpcconsole.cpp | 11 | ||||
-rw-r--r-- | src/qt/rpcconsole.h | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 337e744da8..4a51990f88 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1032,8 +1032,9 @@ void RPCConsole::on_lineEdit_returnPressed() ui->lineEdit->clear(); + WalletModel* wallet_model{nullptr}; #ifdef ENABLE_WALLET - WalletModel* wallet_model = ui->WalletSelector->currentData().value<WalletModel*>(); + wallet_model = ui->WalletSelector->currentData().value<WalletModel*>(); if (m_last_wallet_model != wallet_model) { if (wallet_model) { @@ -1049,7 +1050,10 @@ void RPCConsole::on_lineEdit_returnPressed() //: A console message indicating an entered command is currently being executed. message(CMD_REPLY, tr("Executing…")); m_is_executing = true; - Q_EMIT cmdRequest(cmd, m_last_wallet_model); + + QMetaObject::invokeMethod(m_executor, [this, cmd, wallet_model] { + m_executor->request(cmd, wallet_model); + }); cmd = QString::fromStdString(strFilteredCmd); @@ -1103,9 +1107,6 @@ void RPCConsole::startExecutor() m_is_executing = false; }); - // Requests from this object must go to executor - connect(this, &RPCConsole::cmdRequest, m_executor, &RPCExecutor::request); - // Make sure executor object is deleted in its own thread connect(&thread, &QThread::finished, m_executor, &RPCExecutor::deleteLater); diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 94bc513c5b..1a54fe0cad 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -137,10 +137,6 @@ public Q_SLOTS: /** set which tab has the focus (is visible) */ void setTabFocus(enum TabTypes tabType); -Q_SIGNALS: - // For RPC command executor - void cmdRequest(const QString &command, const WalletModel* wallet_model); - private: struct TranslatedStrings { const QString yes{tr("Yes")}, no{tr("No")}, to{tr("To")}, from{tr("From")}, |