Skip to content

Commit

Permalink
fix(qt): allow refreshing wallet data without crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Dec 6, 2024
1 parent 65800cb commit 3f27e98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ class TransactionTablePriv

/* Query entire wallet anew from core.
*/
void refreshWallet(interfaces::Wallet& wallet)
void refreshWallet(interfaces::Wallet& wallet, bool force = false)
{
parent->beginResetModel();
assert(!m_loaded);
assert(!m_loaded || force);
cachedWallet.clear();
try {
for (const auto& wtx : wallet.getWalletTxs()) {
if (TransactionRecord::showTransaction()) {
Expand All @@ -121,7 +122,6 @@ class TransactionTablePriv
}
parent->endResetModel();
m_loaded = true;
DispatchNotifications();
}

/* Update our model of the wallet incrementally, to synchronize our model of the wallet
Expand Down Expand Up @@ -284,9 +284,9 @@ TransactionTableModel::~TransactionTableModel()
delete priv;
}

void TransactionTableModel::refreshWallet()
void TransactionTableModel::refreshWallet(bool force)
{
priv->refreshWallet(walletModel->wallet());
priv->refreshWallet(walletModel->wallet(), force);
}

/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
Expand Down Expand Up @@ -848,7 +848,7 @@ void TransactionTablePriv::DispatchNotifications()
}
} else {
// it's much faster to just refresh the whole thing instead
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection);
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection, Q_ARG(bool, true));
assert(invoked);
}
vQueueNotifications.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiontablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class TransactionTableModel : public QAbstractTableModel

public Q_SLOTS:
/* Refresh the whole wallet, helpful for huge notification queues */
void refreshWallet();
void refreshWallet(bool foce = false);
/* New transaction, or transaction changed status */
void updateTransaction(const QString &hash, int status, bool showTransaction);
void updateAddressBook(const QString &address, const QString &label,
Expand Down

0 comments on commit 3f27e98

Please sign in to comment.