From 023e63df78b847812040bf6958c97476606dfbfd Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 28 Oct 2014 19:52:21 +0100 Subject: qt: Move transaction notification to transaction table model Move transaction new/update notification to TransactionTableModel. This moves the concerns to where they're actually handled. No need to bounce this through wallet model. - Do wallet transaction preprocessing on signal handler side; avoids locking cs_main/cs_wallet on notification in GUI thread (except for new transactions) --- src/qt/walletmodel.cpp | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) (limited to 'src/qt/walletmodel.cpp') diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index b4733d369e..f7b1552f3e 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -34,7 +34,6 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p cachedEncryptionStatus(Unencrypted), cachedNumBlocks(0) { - fProcessingQueuedTransactions = false; fHaveWatchOnly = wallet->HaveWatchOnly(); fForceCheckBalanceChanged = false; @@ -164,11 +163,8 @@ void WalletModel::checkBalanceChanged() } } -void WalletModel::updateTransaction(const QString &hash, int status) +void WalletModel::updateTransaction() { - if(transactionTableModel) - transactionTableModel->updateTransaction(hash, status); - // Balance and number of transactions might have changed fForceCheckBalanceChanged = true; } @@ -455,45 +451,16 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, Q_ARG(int, status)); } -// queue notifications to show a non freezing progress dialog e.g. for rescan -static bool fQueueNotifications = false; -static std::vector > vQueueNotifications; static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status) { - if (fQueueNotifications) - { - vQueueNotifications.push_back(make_pair(hash, status)); - return; - } - - QString strHash = QString::fromStdString(hash.GetHex()); - - qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status); - QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection, - Q_ARG(QString, strHash), - Q_ARG(int, status)); + Q_UNUSED(wallet); + Q_UNUSED(hash); + Q_UNUSED(status); + QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection); } static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress) { - if (nProgress == 0) - fQueueNotifications = true; - - if (nProgress == 100) - { - fQueueNotifications = false; - if (vQueueNotifications.size() > 10) // prevent balloon spam, show maximum 10 balloons - 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 >().swap(vQueueNotifications); // clear - } - // emits signal "showProgress" QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(title)), -- cgit v1.2.3