Browse Source

Merge pull request #2850 from Diapolo/fix_intro

fix possible infinite loop in intro.cpp thread
0.10
Wladimir J. van der Laan 12 years ago
parent
commit
6d89611c3a
  1. 10
      src/qt/intro.cpp
  2. 1
      src/qt/intro.h

10
src/qt/intro.cpp

@ -25,6 +25,7 @@ static const uint64 BLOCK_CHAIN_SIZE = 10LL * GB_BYTES;
class FreespaceChecker : public QObject class FreespaceChecker : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FreespaceChecker(Intro *intro); FreespaceChecker(Intro *intro);
@ -61,9 +62,16 @@ void FreespaceChecker::check()
/* Find first parent that exists, so that fs::space does not fail */ /* Find first parent that exists, so that fs::space does not fail */
fs::path parentDir = dataDir; fs::path parentDir = dataDir;
fs::path parentDirOld = fs::path();
while(parentDir.has_parent_path() && !fs::exists(parentDir)) while(parentDir.has_parent_path() && !fs::exists(parentDir))
{ {
parentDir = parentDir.parent_path(); parentDir = parentDir.parent_path();
/* Check if we make any progress, break if not to prevent an infinite loop here */
if (parentDirOld == parentDir)
break;
parentDirOld = parentDir;
} }
try { try {
@ -201,7 +209,7 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
} else { } else {
ui->freeSpace->setStyleSheet(""); ui->freeSpace->setStyleSheet("");
} }
ui->freeSpace->setText(freeString+"."); ui->freeSpace->setText(freeString + ".");
} }
/* Don't allow confirm in ERROR state */ /* Don't allow confirm in ERROR state */
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status != FreespaceChecker::ST_ERROR); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status != FreespaceChecker::ST_ERROR);

1
src/qt/intro.h

@ -37,6 +37,7 @@ public:
* Determine default data directory for operating system. * Determine default data directory for operating system.
*/ */
static QString getDefaultDataDirectory(); static QString getDefaultDataDirectory();
signals: signals:
void requestCheck(); void requestCheck();
void stopThread(); void stopThread();

Loading…
Cancel
Save