[PictureLoader] Fix double-queueing bug (#6014)

This commit is contained in:
RickyRister 2025-07-02 20:08:31 -07:00 committed by GitHub
parent c57b84cb17
commit ed82106359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 6 deletions

View file

@ -67,8 +67,7 @@ void PictureLoaderWorker::queueRequest(const QUrl &url, PictureLoaderWorkerWork
QUrl cachedRedirect = getCachedRedirect(url); QUrl cachedRedirect = getCachedRedirect(url);
if (!cachedRedirect.isEmpty()) { if (!cachedRedirect.isEmpty()) {
queueRequest(cachedRedirect, worker); queueRequest(cachedRedirect, worker);
} } else if (cache->metaData(url).isValid()) {
if (cache->metaData(url).isValid()) {
makeRequest(url, worker); makeRequest(url, worker);
} else { } else {
requestLoadQueue.append(qMakePair(url, worker)); requestLoadQueue.append(qMakePair(url, worker));

View file

@ -194,10 +194,7 @@ QImage PictureLoaderWorkerWork::tryLoadImageFromReply(QNetworkReply *reply)
void PictureLoaderWorkerWork::concludeImageLoad(const QImage &image) void PictureLoaderWorkerWork::concludeImageLoad(const QImage &image)
{ {
emit imageLoaded(cardToDownload.getCard(), image); emit imageLoaded(cardToDownload.getCard(), image);
deleteLater();
// Delayed delete is a dumb hack to prevent segfaults due to calling methods on a deleted Work
// TODO: find a more proper way to structure this whole thing
QTimer::singleShot(2000, this, &QObject::deleteLater);
} }
void PictureLoaderWorkerWork::picDownloadChanged() void PictureLoaderWorkerWork::picDownloadChanged()