diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 93886046..180f2808 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -223,7 +223,6 @@ void PictureLoader::setPicDownload(bool _picDownload) PictureLoadingThread::PictureLoadingThread(const QString &_picsPath, bool _picDownload, QObject *parent) : QThread(parent), picsPath(_picsPath), picDownload(_picDownload) { - initMutex.lock(); } PictureLoadingThread::~PictureLoadingThread() @@ -239,12 +238,22 @@ void PictureLoadingThread::run() pictureLoader->setPicsPath(picsPath); pictureLoader->setPicDownload(picDownload); - initMutex.unlock(); + usleep(100); + initWaitCondition.wakeAll(); + exec(); delete pictureLoader; } +void PictureLoadingThread::waitForInit() +{ + QMutex mutex; + mutex.lock(); + initWaitCondition.wait(&mutex); + mutex.unlock(); +} + CardInfo::CardInfo(CardDatabase *_db, const QString &_name, const QString &_manacost, const QString &_cardtype, const QString &_powtough, const QString &_text, const QStringList &_colors, bool _cipt, int _tableRow, const SetList &_sets, const QMap &_picURLs, const QMap &_picURLsHq, const QMap &_picURLsSt) : db(_db), name(_name), sets(_sets), manacost(_manacost), cardtype(_cardtype), powtough(_powtough), text(_text), colors(_colors), picURLs(_picURLs), picURLsHq(_picURLsHq), picURLsSt(_picURLsSt), cipt(_cipt), tableRow(_tableRow), pixmap(NULL) { @@ -427,6 +436,7 @@ CardDatabase::CardDatabase(QObject *parent) loadingThread = new PictureLoadingThread(settingsCache->getPicsPath(), settingsCache->getPicDownload(), this); connect(loadingThread, SIGNAL(imageLoaded(CardInfo *, QImage)), this, SLOT(imageLoaded(CardInfo *, QImage))); loadingThread->start(QThread::LowPriority); + loadingThread->waitForInit(); noCard = new CardInfo(this); noCard->loadPixmap(); // cache pixmap for card back diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index 4e1b43f0..de52765e 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -10,6 +10,7 @@ #include #include #include +#include class CardDatabase; class CardInfo; @@ -87,13 +88,14 @@ private: QString picsPath; bool picDownload; PictureLoader *pictureLoader; - mutable QMutex initMutex; + QWaitCondition initWaitCondition; protected: void run(); public: PictureLoadingThread(const QString &_picsPath, bool _picDownload, QObject *parent); ~PictureLoadingThread(); - PictureLoader *getPictureLoader() const { QMutexLocker locker(&initMutex); return pictureLoader; } + PictureLoader *getPictureLoader() const { return pictureLoader; } + void waitForInit(); signals: void imageLoaded(CardInfo *card, const QImage &image); }; diff --git a/oracle/sets.xml b/oracle/sets.xml index 123d9cb9..30a57698 100644 --- a/oracle/sets.xml +++ b/oracle/sets.xml @@ -3,7 +3,7 @@ http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card http://mtgpics.chutography.com/!set!/!name!.full.jpg http://mtgpics.chutography.com/!set!/!name!.jpg - http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=text&set=["!longname!"] + http://gatherer.wizards.com/Pages/Search/Default.aspx?output=spoiler&method=text&set=["!longname!"]&special=true ARB Alara Reborn @@ -24,6 +24,10 @@ AN Arabian Nights + + AE + Archenemy + BOK Betrayers of Kamigawa @@ -176,6 +180,10 @@ PLC Planar Chaos + + PCH + Planechase + PS Planeshift @@ -296,6 +304,10 @@ US Urza's Saga + + VG + Vanguard + VI Visions