Skip to content

Commit 96c97bb

Browse files
Merge #6456: fix(qt): allow refreshing wallet data without crashing
d296005 fix(qt): allow refreshing wallet data without crashing (UdjinM6) Pull request description: ## Issue being fixed or feature implemented We re-use `refreshWallet` method to optimise loading for huge wallets #5453. However gui121 backport (via 25f87b9) added a condition that prevents this logic. Fix it by allowing explicit wallet refresh (force=true). ## What was done? ## How Has This Been Tested? Open a wallet with 10k+ txes, do `rescanblockchain` via rpc console ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK d296005; Tree-SHA512: d308b3fe9c4fbbfbf2e2339aa14c825aa6f69c72d1f04dab7a14dc1c8721138beca47c7b3801db9782d6cecf2c54023a19a6d22e04b84615f9bddb0b8ec1696c
2 parents 65800cb + d296005 commit 96c97bb

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/qt/transactiontablemodel.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ class TransactionTablePriv
106106

107107
/* Query entire wallet anew from core.
108108
*/
109-
void refreshWallet(interfaces::Wallet& wallet)
109+
void refreshWallet(interfaces::Wallet& wallet, bool force = false)
110110
{
111111
parent->beginResetModel();
112-
assert(!m_loaded);
112+
assert(!m_loaded || force);
113+
cachedWallet.clear();
113114
try {
114115
for (const auto& wtx : wallet.getWalletTxs()) {
115116
if (TransactionRecord::showTransaction()) {
@@ -284,9 +285,9 @@ TransactionTableModel::~TransactionTableModel()
284285
delete priv;
285286
}
286287

287-
void TransactionTableModel::refreshWallet()
288+
void TransactionTableModel::refreshWallet(bool force)
288289
{
289-
priv->refreshWallet(walletModel->wallet());
290+
priv->refreshWallet(walletModel->wallet(), force);
290291
}
291292

292293
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
@@ -846,12 +847,13 @@ void TransactionTablePriv::DispatchNotifications()
846847

847848
vQueueNotifications[i].invoke(parent);
848849
}
850+
vQueueNotifications.clear();
849851
} else {
850-
// it's much faster to just refresh the whole thing instead
851-
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection);
852+
// it's much faster to just drop all the queued notifications and refresh the whole thing instead
853+
vQueueNotifications.clear();
854+
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection, Q_ARG(bool, true));
852855
assert(invoked);
853856
}
854-
vQueueNotifications.clear();
855857
}
856858

857859
void TransactionTableModel::subscribeToCoreSignals()

src/qt/transactiontablemodel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class TransactionTableModel : public QAbstractTableModel
114114

115115
public Q_SLOTS:
116116
/* Refresh the whole wallet, helpful for huge notification queues */
117-
void refreshWallet();
117+
void refreshWallet(bool foce = false);
118118
/* New transaction, or transaction changed status */
119119
void updateTransaction(const QString &hash, int status, bool showTransaction);
120120
void updateAddressBook(const QString &address, const QString &label,

0 commit comments

Comments
 (0)