diff --git a/cockatrice/src/pictureloader.cpp b/cockatrice/src/pictureloader.cpp index 973b81ab..39944b1b 100644 --- a/cockatrice/src/pictureloader.cpp +++ b/cockatrice/src/pictureloader.cpp @@ -19,6 +19,7 @@ #include #include #include +#include // never cache more than 300 cards at once for a single deck #define CACHED_CARD_PER_DECK_MAX 300 @@ -167,9 +168,18 @@ bool PictureLoaderWorker::cardImageExistsOnDisk(QString & setName, QString & cor QImage image; QImageReader imgReader; imgReader.setDecideFormatFromContent(true); + QList picsPaths = QList(); + QDirIterator it(customPicsPath, QDirIterator::Subdirectories); - //The list of paths to the folders in which to search for images - QList picsPaths = QList() << customPicsPath + correctedCardname; + // Recursively check all subdirectories of the CUSTOM folder + while (it.hasNext()) + { + QString thisPath(it.next()); + QFileInfo thisFileInfo(thisPath); + + if (thisFileInfo.isFile() && thisFileInfo.baseName() == correctedCardname) + picsPaths << thisPath; // Card found in the CUSTOM directory, somewhere + } if(!setName.isEmpty()) {