mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
[PictureLoader] Fix freezes from local image search (#5994)
* [PictureLoader] Fix freezes/crashes from parallel folder search * fix build failure
This commit is contained in:
parent
d42bfa88e1
commit
6f3a07b756
11 changed files with 280 additions and 154 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue