Don't reload on error

This commit is contained in:
Atlante45 2015-08-31 22:34:16 +02:00
parent 9a9c703a78
commit 8f74935e96

View file

@ -380,13 +380,14 @@ void Resource::handleReplyFinished() {
case ResourceRequest::Result::Timeout:
qDebug() << "Timed out loading" << _url << "received" << _bytesReceived << "total" << _bytesTotal;
// Fall through to other cases
case ResourceRequest::Result::ServerUnavailable:
case ResourceRequest::Result::Error: {
case ResourceRequest::Result::ServerUnavailable: {
// retry with increasing delays
const int MAX_ATTEMPTS = 8;
const int BASE_DELAY_MS = 1000;
if (++_attempts < MAX_ATTEMPTS) {
QTimer::singleShot(BASE_DELAY_MS * (int)pow(2.0, _attempts), this, &Resource::attemptRequest);
auto waitTime = BASE_DELAY_MS * (int)pow(2.0, _attempts);
qDebug() << "Retrying to load the asset in " << waitTime;
QTimer::singleShot(waitTime, this, &Resource::attemptRequest);
break;
}
// fall through to final failure