diff options
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r-- | src/qt/clientmodel.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index cb832fdd42..3c0564c208 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -55,6 +55,7 @@ int ClientModel::getNumConnections(unsigned int flags) const int ClientModel::getNumBlocks() const { + LOCK(cs_main); return chainActive.Height(); } @@ -76,6 +77,7 @@ quint64 ClientModel::getTotalBytesSent() const QDateTime ClientModel::getLastBlockDate() const { + LOCK(cs_main); if (chainActive.Tip()) return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime()); else @@ -84,11 +86,18 @@ QDateTime ClientModel::getLastBlockDate() const double ClientModel::getVerificationProgress() const { + LOCK(cs_main); return Checkpoints::GuessVerificationProgress(chainActive.Tip()); } 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(); |