Skip to content

Commit

Permalink
qt: Avoid referencing WalletModel class when wallet is disabled
Browse files Browse the repository at this point in the history
This change fixes link errors for Qt 6, but it is meaningful on its own.
  • Loading branch information
hebasto committed Oct 3, 2024
1 parent cfb59da commit 33657e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include <qt/guiutil.h>
#include <qt/peertablesortproxy.h>
#include <qt/platformstyle.h>
#ifdef ENABLE_WALLET
#include <qt/walletmodel.h>
#endif // ENABLE_WALLET
#include <rpc/client.h>
#include <rpc/server.h>
#include <util/strencodings.h>
Expand Down Expand Up @@ -90,7 +92,11 @@ class RPCExecutor : public QObject
explicit RPCExecutor(interfaces::Node& node) : m_node(node) {}

public Q_SLOTS:
#ifdef ENABLE_WALLET
void request(const QString &command, const WalletModel* wallet_model);
#else
void request(const QString &command);
#endif // ENABLE_WALLET

Q_SIGNALS:
void reply(int category, const QString &command);
Expand Down Expand Up @@ -167,7 +173,11 @@ class PeerIdViewDelegate : public QStyledItemDelegate
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
*/

#ifdef ENABLE_WALLET
bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const WalletModel* wallet_model)
#else
bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut)
#endif // ENABLE_WALLET
{
std::vector< std::vector<std::string> > stack;
stack.emplace_back();
Expand Down Expand Up @@ -409,7 +419,11 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
}
}

#ifdef ENABLE_WALLET
void RPCExecutor::request(const QString &command, const WalletModel* wallet_model)
#else
void RPCExecutor::request(const QString &command)
#endif // ENABLE_WALLET
{
try
{
Expand Down Expand Up @@ -439,7 +453,11 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode
" example: getblock(getblockhash(0),1)[tx][0]\n\n")));
return;
}
#ifdef ENABLE_WALLET
if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, wallet_model)) {
#else
if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr)) {
#endif // ENABLE_WALLET
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
return;
}
Expand Down Expand Up @@ -1058,8 +1076,8 @@ void RPCConsole::on_lineEdit_returnPressed()

ui->lineEdit->clear();

WalletModel* wallet_model{nullptr};
#ifdef ENABLE_WALLET
WalletModel* wallet_model{nullptr};
wallet_model = ui->WalletSelector->currentData().value<WalletModel*>();

if (m_last_wallet_model != wallet_model) {
Expand All @@ -1077,9 +1095,15 @@ void RPCConsole::on_lineEdit_returnPressed()
message(CMD_REPLY, tr("Executing…"));
m_is_executing = true;

#ifdef ENABLE_WALLET
QMetaObject::invokeMethod(m_executor, [this, cmd, wallet_model] {
m_executor->request(cmd, wallet_model);
});
#else
QMetaObject::invokeMethod(m_executor, [this, cmd] {
m_executor->request(cmd);
});
#endif // ENABLE_WALLET

cmd = QString::fromStdString(strFilteredCmd);

Expand Down
11 changes: 11 additions & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
class PlatformStyle;
class RPCExecutor;
class RPCTimerInterface;
#ifdef ENABLE_WALLET
class WalletModel;
#endif // ENABLE_WALLET

namespace interfaces {
class Node;
Expand All @@ -46,10 +48,17 @@ class RPCConsole: public QWidget
explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent);
~RPCConsole();

#ifdef ENABLE_WALLET
static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const WalletModel* wallet_model = nullptr);
static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const WalletModel* wallet_model = nullptr) {
return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, wallet_model);
}
#else
static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr);
static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr) {
return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut);
}
#endif // ENABLE_WALLET

void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0, int64_t bestblock_date = 0, double verification_progress = 0.0);

Expand Down Expand Up @@ -173,7 +182,9 @@ public Q_SLOTS:
QCompleter *autoCompleter = nullptr;
QThread thread;
RPCExecutor* m_executor{nullptr};
#ifdef ENABLE_WALLET
WalletModel* m_last_wallet_model{nullptr};
#endif // ENABLE_WALLET
bool m_is_executing{false};
QByteArray m_peer_widget_header_state;
QByteArray m_banlist_widget_header_state;
Expand Down

0 comments on commit 33657e1

Please sign in to comment.