mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[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:
parent
14acf3bf64
commit
9f66a098ac
7 changed files with 108 additions and 11 deletions
|
|
@ -117,6 +117,9 @@ public:
|
|||
public slots:
|
||||
/**
|
||||
* @brief Clears the network disk cache of the worker.
|
||||
*
|
||||
* The clear runs on the worker thread, so this returns before it has completed; connect to
|
||||
* networkCacheCleared() to act once it is done.
|
||||
*/
|
||||
static void clearNetworkCache();
|
||||
|
||||
|
|
@ -131,6 +134,10 @@ public slots:
|
|||
void installPrintingOverride(const ExactCard &originalCard, const ExactCard &overrideCard);
|
||||
void installPrintingOverrideOnLoad(const ExactCard &originalCard, const ExactCard &overrideCard);
|
||||
|
||||
signals:
|
||||
/** @brief Emitted after the worker has finished clearing the network and redirect caches. */
|
||||
void networkCacheCleared();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Triggered when the user changes the picture download settings.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue