Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -316,11 +316,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 315 unmodified lines | ||
| 316 | 316 | QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); |
| 317 | 317 | |
| 318 | 318 | NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); |
| 319 | − QNetworkDiskCache* cache = new QNetworkDiskCache(&networkAccessManager); | |
| 319 | + | |
| 320 | + // Make sure cache on same thread than its parent (NetworkAccessManager) | |
| 321 | + QNetworkDiskCache* cache = new QNetworkDiskCache(); | |
| 322 | + cache->moveToThread(networkAccessManager.thread()); | |
| 323 | + cache->setParent(&networkAccessManager); | |
| 324 | + | |
| 320 | 325 | cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache"); |
| 321 | − QMetaObject::invokeMethod(&networkAccessManager, "setCache", | |
| 322 | − Qt::BlockingQueuedConnection, | |
| 323 | − Q_ARG(QAbstractNetworkCache*, cache)); | |
| 326 | + networkAccessManager.setCache(cache); | |
| 324 | 327 | |
| 325 | 328 | ResourceCache::setRequestLimit(3); |
| 326 | 329 | |