Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 4 files). Show all
Unified · Split
| @@ -251,18 +251,16 @@ QSharedPointer<NetworkGeometry> GeometryCache::getGeometry(const QUrl& url) { · 250 unmodified lines | ||
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | NetworkGeometry::NetworkGeometry(const QUrl& url) : |
| 254 | + _modelRequest(url), | |
| 254 | 255 | _modelReply(NULL), |
| 255 | − _mappingReply(NULL) | |
| 256 | + _mappingReply(NULL), | |
| 257 | + _attempts(0) | |
| 256 | 258 | { |
| 257 | 259 | if (!url.isValid()) { |
| 258 | 260 | return; |
| 259 | 261 | } |
| 260 | − QNetworkRequest modelRequest(url); | |
| 261 | − modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); | |
| 262 | − _modelReply = Application::getInstance()->getNetworkAccessManager()->get(modelRequest); | |
| 263 | − | |
| 264 | − connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping())); | |
| 265 | − connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError())); | |
| 262 | + _modelRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); | |
| 263 | + makeModelRequest(); | |
| 266 | 264 | |
| 267 | 265 | QUrl mappingURL = url; |
| 268 | 266 | QString path = url.path(); |
| @@ -312,12 +310,30 @@ glm::vec4 NetworkGeometry::computeAverageColor() const { · 43 unmodified lines | ||
| 312 | 310 | return (totalTriangles == 0) ? glm::vec4(1.0f, 1.0f, 1.0f, 1.0f) : totalColor / totalTriangles; |
| 313 | 311 | } |
| 314 | 312 | |
| 313 | +void NetworkGeometry::makeModelRequest() { | |
| 314 | + _modelReply = Application::getInstance()->getNetworkAccessManager()->get(_modelRequest); | |
| 315 | + | |
| 316 | + connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(maybeReadModelWithMapping())); | |
| 317 | + connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError())); | |
| 318 | +} | |
| 319 | + | |
| 315 | 320 | void NetworkGeometry::handleModelReplyError() { |
| 316 | − qDebug() << _modelReply->errorString() << "\n"; | |
| 321 | + QDebug debug = qDebug() << _modelReply->errorString(); | |
| 317 | 322 | |
| 318 | 323 | _modelReply->disconnect(this); |
| 319 | 324 | _modelReply->deleteLater(); |
| 320 | 325 | _modelReply = NULL; |
| 326 | + | |
| 327 | + // retry with increasing delays | |
| 328 | + const int MAX_ATTEMPTS = 8; | |
| 329 | + const int BASE_DELAY_MS = 1000; | |
| 330 | + if (++_attempts < MAX_ATTEMPTS) { | |
| 331 | + QTimer::singleShot(BASE_DELAY_MS * (int)pow(2.0, _attempts), this, SLOT(makeModelRequest())); | |
| 332 | + debug << " -- retrying...\n"; | |
| 333 | + | |
| 334 | + } else { | |
| 335 | + debug << "\n"; | |
| 336 | + } | |
| 321 | 337 | } |
| 322 | 338 | |
| 323 | 339 | void NetworkGeometry::handleMappingReplyError() { |