Skip to content

Commit

Permalink
Merge pull request #2469 from Diapolo/clientmodel-progress
Browse files Browse the repository at this point in the history
Bitcoin-Qt: emit numBlocksChanged for changed reindex or importing state
  • Loading branch information
gavinandresen committed Apr 9, 2013
2 parents 54c0b3e + 87dd603 commit c553fe8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ static const int64 nClientStartupTime = GetTime();

ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QObject(parent), optionsModel(optionsModel),
cachedNumBlocks(0), cachedNumBlocksOfPeers(0), numBlocksAtStartup(-1), pollTimer(0)
cachedNumBlocks(0), cachedNumBlocksOfPeers(0),
cachedReindexing(0), cachedImporting(0),
numBlocksAtStartup(-1), pollTimer(0)
{
pollTimer = new QTimer(this);
pollTimer->setInterval(MODEL_UPDATE_DELAY);
Expand Down Expand Up @@ -70,10 +72,14 @@ void ClientModel::updateTimer()
int newNumBlocks = getNumBlocks();
int newNumBlocksOfPeers = getNumBlocksOfPeers();

if(cachedNumBlocks != newNumBlocks || cachedNumBlocksOfPeers != newNumBlocksOfPeers)
// check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state
if (cachedNumBlocks != newNumBlocks || cachedNumBlocksOfPeers != newNumBlocksOfPeers ||
cachedReindexing != fReindex || cachedImporting != fImporting)
{
cachedNumBlocks = newNumBlocks;
cachedNumBlocksOfPeers = newNumBlocksOfPeers;
cachedReindexing = fReindex;
cachedImporting = fImporting;

// ensure we return the maximum of newNumBlocksOfPeers and newNumBlocks to not create weird displays in the GUI
emit numBlocksChanged(newNumBlocks, std::max(newNumBlocksOfPeers, newNumBlocks));
Expand Down
2 changes: 2 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class ClientModel : public QObject

int cachedNumBlocks;
int cachedNumBlocksOfPeers;
bool cachedReindexing;
bool cachedImporting;

int numBlocksAtStartup;

Expand Down

0 comments on commit c553fe8

Please sign in to comment.