From ed821063599ff3dc70168a674de3585d0a8b48e3 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Wed, 2 Jul 2025 20:08:31 -0700 Subject: [PATCH] [PictureLoader] Fix double-queueing bug (#6014) --- .../src/client/ui/picture_loader/picture_loader_worker.cpp | 3 +-- .../client/ui/picture_loader/picture_loader_worker_work.cpp | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) 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 6d7478765..a8b5dd6a0 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp @@ -67,8 +67,7 @@ void PictureLoaderWorker::queueRequest(const QUrl &url, PictureLoaderWorkerWork QUrl cachedRedirect = getCachedRedirect(url); if (!cachedRedirect.isEmpty()) { queueRequest(cachedRedirect, worker); - } - if (cache->metaData(url).isValid()) { + } else if (cache->metaData(url).isValid()) { makeRequest(url, worker); } else { requestLoadQueue.append(qMakePair(url, worker)); diff --git a/cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.cpp b/cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.cpp index b94772b24..533f4c116 100644 --- a/cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.cpp +++ b/cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.cpp @@ -194,10 +194,7 @@ QImage PictureLoaderWorkerWork::tryLoadImageFromReply(QNetworkReply *reply) void PictureLoaderWorkerWork::concludeImageLoad(const QImage &image) { emit imageLoaded(cardToDownload.getCard(), image); - - // 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); + deleteLater(); } void PictureLoaderWorkerWork::picDownloadChanged()