aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactiontablemodel.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-04-15 17:38:25 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-04-18 12:49:41 +0200
commit55a1db4fa2cf62b9766ef382c1e14b3ecbdf67fe (patch)
tree1ff19f533ab0221e27dd16c3d401c4d54dfbca7b /src/qt/transactiontablemodel.cpp
parente07c943ce8df6c6cb3ece3fc676911ddb43ca184 (diff)
downloadbitcoin-55a1db4fa2cf62b9766ef382c1e14b3ecbdf67fe.tar.xz
Solve chainActive-related locking issues
- In wallet and GUI code LOCK cs_main as well as cs_wallet when necessary - In main.cpp SendMessages move the TRY_LOCK(cs_main) up, to encompass the call to IsInitialBlockDownload. - Make ActivateBestChain, AddToBlockIndex, IsInitialBlockDownload, InitBlockIndex acquire the cs_main lock Fixes #3997
Diffstat (limited to 'src/qt/transactiontablemodel.cpp')
-rw-r--r--src/qt/transactiontablemodel.cpp41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 959987461f..aaecf88c25 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -78,7 +78,7 @@ public:
qDebug() << "TransactionTablePriv::refreshWallet";
cachedWallet.clear();
{
- LOCK(wallet->cs_wallet);
+ LOCK2(cs_main, wallet->cs_wallet);
for(std::map<uint256, CWalletTx>::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it)
{
if(TransactionRecord::showTransaction(it->second))
@@ -96,7 +96,7 @@ public:
{
qDebug() << "TransactionTablePriv::updateWallet : " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
{
- LOCK(wallet->cs_wallet);
+ LOCK2(cs_main, wallet->cs_wallet);
// Find transaction in wallet
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
@@ -190,16 +190,14 @@ public:
// If a status update is needed (blocks came in since last check),
// update the status of this transaction from the wallet. Otherwise,
// simply re-use the cached status.
+ LOCK2(cs_main, wallet->cs_wallet);
if(rec->statusUpdateNeeded())
{
- {
- LOCK(wallet->cs_wallet);
- std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
+ std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
- if(mi != wallet->mapWallet.end())
- {
- rec->updateStatus(mi->second);
- }
+ if(mi != wallet->mapWallet.end())
+ {
+ rec->updateStatus(mi->second);
}
}
return rec;
@@ -213,7 +211,7 @@ public:
QString describe(TransactionRecord *rec, int unit)
{
{
- LOCK(wallet->cs_wallet);
+ LOCK2(cs_main, wallet->cs_wallet);
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
if(mi != wallet->mapWallet.end())
{
@@ -228,17 +226,12 @@ TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *paren
QAbstractTableModel(parent),
wallet(wallet),
walletModel(parent),
- priv(new TransactionTablePriv(wallet, this)),
- cachedNumBlocks(0)
+ priv(new TransactionTablePriv(wallet, this))
{
columns << QString() << tr("Date") << tr("Type") << tr("Address") << tr("Amount");
priv->refreshWallet();
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(updateConfirmations()));
- timer->start(MODEL_UPDATE_DELAY);
-
connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
}
@@ -257,16 +250,12 @@ void TransactionTableModel::updateTransaction(const QString &hash, int status)
void TransactionTableModel::updateConfirmations()
{
- if(chainActive.Height() != cachedNumBlocks)
- {
- cachedNumBlocks = chainActive.Height();
- // Blocks came in since last poll.
- // Invalidate status (number of confirmations) and (possibly) description
- // for all rows. Qt is smart enough to only actually request the data for the
- // visible rows.
- emit dataChanged(index(0, Status), index(priv->size()-1, Status));
- emit dataChanged(index(0, ToAddress), index(priv->size()-1, ToAddress));
- }
+ // Blocks came in since last poll.
+ // Invalidate status (number of confirmations) and (possibly) description
+ // for all rows. Qt is smart enough to only actually request the data for the
+ // visible rows.
+ emit dataChanged(index(0, Status), index(priv->size()-1, Status));
+ emit dataChanged(index(0, ToAddress), index(priv->size()-1, ToAddress));
}
int TransactionTableModel::rowCount(const QModelIndex &parent) const