Mercurial > hg > bitcoin
changeset 3200:2b044778b85f draft
Merge pull request #1575 from laanwj/2012_07_persistentbalancecheck
(UI) Persistently poll for balance change when number of blocks changed
author | Wladimir J. van der Laan <laanwj@gmail.com> |
---|---|
date | Fri, 13 Jul 2012 04:52:40 -0700 |
parents | b63a5263d11a (current diff) 72e540227482 (diff) |
children | ae3d061d9a9f |
files | |
diffstat | 1 files changed, 10 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -23,13 +23,10 @@ addressTableModel = new AddressTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); - // This single-shot timer will be fired from the 'checkBalancedChanged' - // method repeatedly while either of the unconfirmed or immature balances - // are non-zero + // This timer will be fired repeatedly to update the balance pollTimer = new QTimer(this); - pollTimer->setInterval(MODEL_UPDATE_DELAY); - pollTimer->setSingleShot(true); connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged())); + pollTimer->start(MODEL_UPDATE_DELAY); subscribeToCoreSignals(); } @@ -74,13 +71,12 @@ void WalletModel::pollBalanceChanged() { - if(nBestHeight != cachedNumBlocks) { + if(nBestHeight != cachedNumBlocks) + { + // Balance and number of transactions might have changed cachedNumBlocks = nBestHeight; checkBalanceChanged(); } - - if(cachedUnconfirmedBalance || cachedImmatureBalance) - pollTimer->start(); } void WalletModel::checkBalanceChanged() @@ -89,7 +85,8 @@ qint64 newUnconfirmedBalance = getUnconfirmedBalance(); qint64 newImmatureBalance = getImmatureBalance(); - if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) { + if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) + { cachedBalance = newBalance; cachedUnconfirmedBalance = newUnconfirmedBalance; cachedImmatureBalance = newImmatureBalance; @@ -105,13 +102,11 @@ // Balance and number of transactions might have changed checkBalanceChanged(); - if(cachedUnconfirmedBalance || cachedImmatureBalance) - pollTimer->start(); - int newNumTransactions = getNumTransactions(); - if(cachedNumTransactions != newNumTransactions) { + if(cachedNumTransactions != newNumTransactions) + { + cachedNumTransactions = newNumTransactions; emit numTransactionsChanged(newNumTransactions); - cachedNumTransactions = newNumTransactions; } }