[PictureLoader] Fix worker thread shutdown and cross-thread cache clearing (#7292)

* [PictureLoader] Fix worker thread shutdown and cross-thread cache clearing

clearNetworkCache() ran directly on the UI thread while the worker thread
owned the disk cache and redirect cache, racing cache reads/writes. Make it
a worker-thread slot invoked via a blocking queued call when the thread is
running, so the 'Cached card pictures have been reset.' message is truthful.

The worker thread was also never quit()/wait()ed: both destructors only
deleteLater'd their objects, so Qt warned 'QThread: Destroyed while thread
is still running' and leaked a running loop at exit. Wire the worker's
finished() signal to its own deleteLater() (canonical worker-object
pattern), add shutdownThread() to stop the loop, and let CardPictureLoader
destroy the QThread only after wait() has returned.

* [PictureLoader] Guard cache teardown and stop blocking the UI thread

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-09-21 18:30:03 +02:00 committed by GitHub
parent 14acf3bf64
commit 9f66a098ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 108 additions and 11 deletions

View file

@ -181,9 +181,14 @@ StorageSettingsPage::StorageSettingsPage()
void StorageSettingsPage::clearDownloadedPicsButtonClicked()
{
CardPictureLoader::clearNetworkCache();
// The network cache is cleared asynchronously on the worker thread, so wait for the completion
// signal before confirming; the in-memory pixmap cache is cleared synchronously right away.
connect(
&CardPictureLoader::getInstance(), &CardPictureLoader::networkCacheCleared, this,
[this] { QMessageBox::information(this, tr("Success"), tr("Cached card pictures have been reset.")); },
Qt::SingleShotConnection);
CardPictureLoader::clearPixmapCache();
QMessageBox::information(this, tr("Success"), tr("Cached card pictures have been reset."));
CardPictureLoader::clearNetworkCache();
}
void StorageSettingsPage::clearImageBackupsButtonClicked()