[PictureLoader] Fix freezes from local image search (#5994)

* [PictureLoader] Fix freezes/crashes from parallel folder search

* fix build failure
This commit is contained in:
RickyRister 2025-06-21 18:10:29 -07:00 committed by GitHub
parent d42bfa88e1
commit 6f3a07b756
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 280 additions and 154 deletions

View file

@ -0,0 +1,40 @@
#ifndef PICTURE_LOADER_LOCAL_H
#define PICTURE_LOADER_LOCAL_H
#include "../../../game/cards/card_info.h"
#include <QLoggingCategory>
#include <QObject>
inline Q_LOGGING_CATEGORY(PictureLoaderLocalLog, "picture_loader.local");
/**
* Handles searching for and loading card images from the local pics and custom image folders.
* This class maintains an index of the CUSTOM folder, to avoid repeatedly searching the entire directory.
*/
class PictureLoaderLocal : public QObject
{
Q_OBJECT
public:
explicit PictureLoaderLocal(QObject *parent);
QImage tryLoad(const CardInfoPtr &toLoad) const;
private:
QString picsPath, customPicsPath;
bool overrideAllCardArtWithPersonalPreference;
QMultiHash<QString, QString> customFolderIndex; // multimap of cardName to picPaths
void createIndex();
QImage
tryLoadCardImageFromDisk(const QString &setName, const QString &correctedCardName, bool searchCustomPics) const;
private slots:
void picsPathChanged();
void setOverrideAllCardArtWithPersonalPreference(bool _overrideAllCardArtWithPersonalPreference);
};
#endif // PICTURE_LOADER_LOCAL_H