aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletmodel.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-04-23 17:05:36 +0200
committerWladimir J. van der Laan <[email protected]>2014-04-23 17:06:28 +0200
commit89bbd54fbfbb1b21257d436731868455821a101e (patch)
treea394f051221cb79d684d5643855597187fabc210 /src/qt/walletmodel.cpp
parentMerge pull request #4055 (diff)
parentAdd missing AssertLockHeld in ConnectBlock (diff)
downloaddiscoin-89bbd54fbfbb1b21257d436731868455821a101e.tar.xz
discoin-89bbd54fbfbb1b21257d436731868455821a101e.zip
Merge pull request #4085
b39a07d Add missing AssertLockHeld in ConnectBlock (Wladimir J. van der Laan) 41106a5 qt: get required locks upfront in polling functions (Wladimir J. van der Laan) ed67100 Add required locks in tests (Wladimir J. van der Laan)
Diffstat (limited to 'src/qt/walletmodel.cpp')
-rw-r--r--src/qt/walletmodel.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 61f26107a..37d82ec06 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -98,18 +98,21 @@ void WalletModel::updateStatus()
void WalletModel::pollBalanceChanged()
{
- 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)
+ // Get required locks upfront. This avoids the GUI from getting stuck on
+ // periodical polls if the core is holding the locks for a longer time -
+ // for example, during a wallet rescan.
+ TRY_LOCK(cs_main, lockMain);
+ if(!lockMain)
+ return;
+ TRY_LOCK(wallet->cs_wallet, lockWallet);
+ if(!lockWallet)
+ return;
+
+ if(chainActive.Height() != cachedNumBlocks)
{
+ // Balance and number of transactions might have changed
+ cachedNumBlocks = chainActive.Height();
+
checkBalanceChanged();
if(transactionTableModel)
transactionTableModel->updateConfirmations();