Browse Source

Merge pull request #4530

acd432b [Qt] Prevent balloon-spam after rescan (Cozz Lovan)
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
ba738634ae
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 13
      src/qt/walletmodel.cpp
  2. 4
      src/qt/walletmodel.h
  3. 2
      src/qt/walletview.cpp

13
src/qt/walletmodel.cpp

@ -35,6 +35,8 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
cachedEncryptionStatus(Unencrypted), cachedEncryptionStatus(Unencrypted),
cachedNumBlocks(0) cachedNumBlocks(0)
{ {
fProcessingQueuedTransactions = false;
addressTableModel = new AddressTableModel(wallet, this); addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this);
recentRequestsTableModel = new RecentRequestsTableModel(wallet, this); recentRequestsTableModel = new RecentRequestsTableModel(wallet, this);
@ -492,8 +494,15 @@ static void ShowProgress(WalletModel *walletmodel, const std::string &title, int
if (nProgress == 100) if (nProgress == 100)
{ {
fQueueNotifications = false; fQueueNotifications = false;
BOOST_FOREACH(const PAIRTYPE(uint256, ChangeType)& notification, vQueueNotifications) if (vQueueNotifications.size() > 10) // prevent balloon spam, show maximum 10 balloons
NotifyTransactionChanged(walletmodel, NULL, notification.first, notification.second); QMetaObject::invokeMethod(walletmodel, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
{
if (vQueueNotifications.size() - i <= 10)
QMetaObject::invokeMethod(walletmodel, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
NotifyTransactionChanged(walletmodel, NULL, vQueueNotifications[i].first, vQueueNotifications[i].second);
}
std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear
} }
} }

4
src/qt/walletmodel.h

@ -133,6 +133,7 @@ public:
qint64 getWatchImmatureBalance() const; qint64 getWatchImmatureBalance() const;
int getNumTransactions() const; int getNumTransactions() const;
EncryptionStatus getEncryptionStatus() const; EncryptionStatus getEncryptionStatus() const;
bool processingQueuedTransactions() { return fProcessingQueuedTransactions; }
// Check address for validity // Check address for validity
bool validateAddress(const QString &address); bool validateAddress(const QString &address);
@ -196,6 +197,7 @@ public:
private: private:
CWallet *wallet; CWallet *wallet;
bool fProcessingQueuedTransactions;
// Wallet has an options model for wallet-specific options // Wallet has an options model for wallet-specific options
// (transaction fee, for example) // (transaction fee, for example)
@ -256,6 +258,8 @@ public slots:
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status); void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status);
/* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */ /* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */
void pollBalanceChanged(); void pollBalanceChanged();
/* Needed to update fProcessingQueuedTransactions through a QueuedConnection */
void setProcessingQueuedTransactions(bool value) { fProcessingQueuedTransactions = value; }
}; };
#endif // WALLETMODEL_H #endif // WALLETMODEL_H

2
src/qt/walletview.cpp

@ -137,7 +137,7 @@ void WalletView::setWalletModel(WalletModel *walletModel)
void WalletView::processNewTransaction(const QModelIndex& parent, int start, int /*end*/) void WalletView::processNewTransaction(const QModelIndex& parent, int start, int /*end*/)
{ {
// Prevent balloon-spam when initial block download is in progress // Prevent balloon-spam when initial block download is in progress
if (!walletModel || !clientModel || clientModel->inInitialBlockDownload()) if (!walletModel || walletModel->processingQueuedTransactions() || !clientModel || clientModel->inInitialBlockDownload())
return; return;
TransactionTableModel *ttm = walletModel->getTransactionTableModel(); TransactionTableModel *ttm = walletModel->getTransactionTableModel();

Loading…
Cancel
Save