Skip to content

Commit ec55834

Browse files
committed
fix(qt): allow refreshing wallet data without crashing
1 parent 65800cb commit ec55834

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/qt/transactiontablemodel.cpp

Lines changed: 9 additions & 6 deletions
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()) {
@@ -121,7 +122,9 @@ class TransactionTablePriv
121122
}
122123
parent->endResetModel();
123124
m_loaded = true;
124-
DispatchNotifications();
125+
if (!force) {
126+
DispatchNotifications();
127+
}
125128
}
126129

127130
/* Update our model of the wallet incrementally, to synchronize our model of the wallet
@@ -284,9 +287,9 @@ TransactionTableModel::~TransactionTableModel()
284287
delete priv;
285288
}
286289

287-
void TransactionTableModel::refreshWallet()
290+
void TransactionTableModel::refreshWallet(bool force)
288291
{
289-
priv->refreshWallet(walletModel->wallet());
292+
priv->refreshWallet(walletModel->wallet(), force);
290293
}
291294

292295
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
@@ -848,7 +851,7 @@ void TransactionTablePriv::DispatchNotifications()
848851
}
849852
} else {
850853
// it's much faster to just refresh the whole thing instead
851-
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection);
854+
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection, Q_ARG(bool, true));
852855
assert(invoked);
853856
}
854857
vQueueNotifications.clear();

src/qt/transactiontablemodel.h

Lines changed: 1 addition & 1 deletion
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)