diff options
| author | Wladimir J. van der Laan <[email protected]> | 2014-04-22 10:01:35 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2014-04-22 13:35:37 +0200 |
| commit | 2bbecc84e2f2969e5649fdaeb1a0ca239b03fe44 (patch) | |
| tree | 31d5a8fb1e30587cdca82618cf17de127d61ee2c /src/qt/walletmodel.cpp | |
| parent | Merge pull request #4048 from sipa/nobigb58 (diff) | |
| parent | Solve chainActive-related locking issues (diff) | |
| download | discoin-2bbecc84e2f2969e5649fdaeb1a0ca239b03fe44.tar.xz discoin-2bbecc84e2f2969e5649fdaeb1a0ca239b03fe44.zip | |
Merge pull request #4058
55a1db4 Solve chainActive-related locking issues (Wladimir J. van der Laan)
e07c943 Add AssertLockHeld for cs_main to ChainActive-using functions (Wladimir J. van der Laan)
Diffstat (limited to 'src/qt/walletmodel.cpp')
| -rw-r--r-- | src/qt/walletmodel.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 424c9ee27..61f26107a 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -98,11 +98,21 @@ void WalletModel::updateStatus() void WalletModel::pollBalanceChanged() { - if(chainActive.Height() != cachedNumBlocks) + bool heightChanged = false; + { + LOCK(cs_main); + if(chainActive.Height() != cachedNumBlocks) + { + // Balance and number of transactions might have changed + cachedNumBlocks = chainActive.Height(); + heightChanged = true; + } + } + if(heightChanged) { - // Balance and number of transactions might have changed - cachedNumBlocks = chainActive.Height(); checkBalanceChanged(); + if(transactionTableModel) + transactionTableModel->updateConfirmations(); } } @@ -520,7 +530,7 @@ bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const // returns a list of COutputs from COutPoints void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs) { - LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet); BOOST_FOREACH(const COutPoint& outpoint, vOutpoints) { if (!wallet->mapWallet.count(outpoint.hash)) continue; @@ -533,7 +543,7 @@ void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vect bool WalletModel::isSpent(const COutPoint& outpoint) const { - LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet); return wallet->IsSpent(outpoint.hash, outpoint.n); } @@ -543,7 +553,7 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) std::vector<COutput> vCoins; wallet->AvailableCoins(vCoins); - LOCK(wallet->cs_wallet); // ListLockedCoins, mapWallet + LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet std::vector<COutPoint> vLockedCoins; wallet->ListLockedCoins(vLockedCoins); @@ -575,25 +585,25 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const { - LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet); return wallet->IsLockedCoin(hash, n); } void WalletModel::lockCoin(COutPoint& output) { - LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet); wallet->LockCoin(output); } void WalletModel::unlockCoin(COutPoint& output) { - LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet); wallet->UnlockCoin(output); } void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts) { - LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet); wallet->ListLockedCoins(vOutpts); } |