diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp b/cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp index a1cfa53be..89559983c 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp @@ -244,6 +244,23 @@ QNetworkReply *PictureLoaderWorker::makeRequest(const QUrl &url) QNetworkRequest req(url); + // QNetworkDiskCache leaks file descriptors when downloading compressed + // files, see https://bugreports.qt.io/browse/QTBUG-135641 + // + // We can set the Accept-Encoding header manually to disable Qt's automatic + // response decompression, but then we would have to deal with decompression + // ourselves. + // + // Since we are dowloading images that are usually stored in a + // compressed format (e.g. jpeg or webp), it's not clear compression at the + // HTTP level helps; in fact, images are typically returned without + // compression. Redirects, on the other hand, are compressed and cause file + // descriptor leaks -- but since redirects have no payload, we don't really + // care either. + // + // In the end, just do the simple thing and disable HTTP compression. + req.setRawHeader("accept-encoding", "identity"); + if (!picDownload) { req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache); }