aboutsummaryrefslogtreecommitdiff
path: root/src/qt/clientmodel.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-04-23 08:40:48 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-04-23 09:07:18 +0200
commit41106a50d2be9358ab19e75c1d6d075a773525b7 (patch)
treecdda729dd8d02fc4052531ee902f51a21b8a2b12 /src/qt/clientmodel.cpp
parented671005654136b728768a423c8ac7f4e1ce637f (diff)
qt: get required locks upfront in polling functions
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.
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r--src/qt/clientmodel.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 287296644c..3c0564c208 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -92,6 +92,12 @@ double ClientModel::getVerificationProgress() const
void ClientModel::updateTimer()
{
+ // Get required lock 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;
// Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change.
// Periodically check and update with a timer.
int newNumBlocks = getNumBlocks();