mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-22 01:40:48 +02:00
Merge bitcoin-core/gui#589: Getting ready to Qt 6 (7/n). Do not pass WalletModel*
to a queued connection
ab73d5985de5d9c4d1e3fd0f4d9d88a0908ea319 Do not pass `WalletModel*` to queued connection (Hennadii Stepanov) fdf72859504d063d0a6b60a6dac5ad170bd86440 refactor: Make `RPCExecutor*` a member of the `RPCConsole` class (Hennadii Stepanov) 61457c179aec23227dcf3952c575052204103b50 refactor: Guard `RPCConsole::{add,remove}Wallet()` with `ENABLE_WALLET` (Hennadii Stepanov) Pull request description: On master (094d9fda5ccee7d78a2e3d8b1eec17b8b6a33466), the following queued connection094d9fda5c/src/qt/rpcconsole.cpp (L1107)
uses a `const WalletModel*` parameter regardless whether the `ENABLE_WALLET` macro is defined. Although this code works in Qt 5, it is flawed. On Qt 6, the code gets broken because the fully defined `WalletModel` type is required which is not the case if `ENABLE_WALLET` is undefined. This PR fixes the issue described above. ACKs for top commit: promag: ACK ab73d5985de5d9c4d1e3fd0f4d9d88a0908ea319 jarolrod: code review ACKab73d5985d
Tree-SHA512: 544ba984da4480aa34f1516a737d6034eb5616b8f78db38dc9bf2d15c15251957bc0b0c9b0d5a365552da9b64a850801a6f4caa12b0ac220f51bd2b334fbe545
This commit is contained in:
commit
0b8e2868f5
@ -1032,8 +1032,9 @@ void RPCConsole::on_lineEdit_returnPressed()
|
|||||||
|
|
||||||
ui->lineEdit->clear();
|
ui->lineEdit->clear();
|
||||||
|
|
||||||
|
WalletModel* wallet_model{nullptr};
|
||||||
#ifdef ENABLE_WALLET
|
#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 (m_last_wallet_model != wallet_model) {
|
||||||
if (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.
|
//: A console message indicating an entered command is currently being executed.
|
||||||
message(CMD_REPLY, tr("Executing…"));
|
message(CMD_REPLY, tr("Executing…"));
|
||||||
m_is_executing = true;
|
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);
|
cmd = QString::fromStdString(strFilteredCmd);
|
||||||
|
|
||||||
@ -1091,11 +1095,11 @@ void RPCConsole::browseHistory(int offset)
|
|||||||
|
|
||||||
void RPCConsole::startExecutor()
|
void RPCConsole::startExecutor()
|
||||||
{
|
{
|
||||||
RPCExecutor *executor = new RPCExecutor(m_node);
|
m_executor = new RPCExecutor(m_node);
|
||||||
executor->moveToThread(&thread);
|
m_executor->moveToThread(&thread);
|
||||||
|
|
||||||
// Replies from executor object must go to this object
|
// Replies from executor object must go to this object
|
||||||
connect(executor, &RPCExecutor::reply, this, [this](int category, const QString& command) {
|
connect(m_executor, &RPCExecutor::reply, this, [this](int category, const QString& command) {
|
||||||
// Remove "Executing…" message.
|
// Remove "Executing…" message.
|
||||||
ui->messagesWidget->undo();
|
ui->messagesWidget->undo();
|
||||||
message(category, command);
|
message(category, command);
|
||||||
@ -1103,16 +1107,13 @@ void RPCConsole::startExecutor()
|
|||||||
m_is_executing = false;
|
m_is_executing = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Requests from this object must go to executor
|
|
||||||
connect(this, &RPCConsole::cmdRequest, executor, &RPCExecutor::request);
|
|
||||||
|
|
||||||
// Make sure executor object is deleted in its own thread
|
// Make sure executor object is deleted in its own thread
|
||||||
connect(&thread, &QThread::finished, executor, &RPCExecutor::deleteLater);
|
connect(&thread, &QThread::finished, m_executor, &RPCExecutor::deleteLater);
|
||||||
|
|
||||||
// Default implementation of QThread::run() simply spins up an event loop in the thread,
|
// Default implementation of QThread::run() simply spins up an event loop in the thread,
|
||||||
// which is what we want.
|
// which is what we want.
|
||||||
thread.start();
|
thread.start();
|
||||||
QTimer::singleShot(0, executor, []() {
|
QTimer::singleShot(0, m_executor, []() {
|
||||||
util::ThreadRename("qt-rpcconsole");
|
util::ThreadRename("qt-rpcconsole");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
#ifndef BITCOIN_QT_RPCCONSOLE_H
|
#ifndef BITCOIN_QT_RPCCONSOLE_H
|
||||||
#define BITCOIN_QT_RPCCONSOLE_H
|
#define BITCOIN_QT_RPCCONSOLE_H
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
#include <qt/peertablemodel.h>
|
#include <qt/peertablemodel.h>
|
||||||
|
|
||||||
@ -17,6 +21,7 @@
|
|||||||
|
|
||||||
class ClientModel;
|
class ClientModel;
|
||||||
class PlatformStyle;
|
class PlatformStyle;
|
||||||
|
class RPCExecutor;
|
||||||
class RPCTimerInterface;
|
class RPCTimerInterface;
|
||||||
class WalletModel;
|
class WalletModel;
|
||||||
|
|
||||||
@ -49,8 +54,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0, int64_t bestblock_date = 0, double verification_progress = 0.0);
|
void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0, int64_t bestblock_date = 0, double verification_progress = 0.0);
|
||||||
void addWallet(WalletModel * const walletModel);
|
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
|
void addWallet(WalletModel* const walletModel);
|
||||||
void removeWallet(WalletModel* const walletModel);
|
void removeWallet(WalletModel* const walletModel);
|
||||||
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
enum MessageClass {
|
enum MessageClass {
|
||||||
MC_ERROR,
|
MC_ERROR,
|
||||||
@ -129,10 +137,6 @@ public Q_SLOTS:
|
|||||||
/** set which tab has the focus (is visible) */
|
/** set which tab has the focus (is visible) */
|
||||||
void setTabFocus(enum TabTypes tabType);
|
void setTabFocus(enum TabTypes tabType);
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
// For RPC command executor
|
|
||||||
void cmdRequest(const QString &command, const WalletModel* wallet_model);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TranslatedStrings {
|
struct TranslatedStrings {
|
||||||
const QString yes{tr("Yes")}, no{tr("No")}, to{tr("To")}, from{tr("From")},
|
const QString yes{tr("Yes")}, no{tr("No")}, to{tr("To")}, from{tr("From")},
|
||||||
@ -166,6 +170,7 @@ private:
|
|||||||
int consoleFontSize = 0;
|
int consoleFontSize = 0;
|
||||||
QCompleter *autoCompleter = nullptr;
|
QCompleter *autoCompleter = nullptr;
|
||||||
QThread thread;
|
QThread thread;
|
||||||
|
RPCExecutor* m_executor{nullptr};
|
||||||
WalletModel* m_last_wallet_model{nullptr};
|
WalletModel* m_last_wallet_model{nullptr};
|
||||||
bool m_is_executing{false};
|
bool m_is_executing{false};
|
||||||
QByteArray m_peer_widget_header_state;
|
QByteArray m_peer_widget_header_state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user