Fix #745
This commit is contained in:
parent
ef654341fa
commit
70b047adcb
2 changed files with 22 additions and 9 deletions
|
@ -142,11 +142,11 @@ void PictureLoader::processLoadQueue()
|
||||||
loadQueueRunning = false;
|
loadQueueRunning = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PictureToLoad ptl = loadQueue.takeFirst();
|
cardBeingLoaded = loadQueue.takeFirst();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
QString setName = ptl.getSetName();
|
QString setName = cardBeingLoaded.getSetName();
|
||||||
QString correctedCardname = ptl.getCard()->getCorrectedName();
|
QString correctedCardname = cardBeingLoaded.getCard()->getCorrectedName();
|
||||||
qDebug() << "Trying to load picture (set: " << setName << " card: " << correctedCardname << ")";
|
qDebug() << "Trying to load picture (set: " << setName << " card: " << correctedCardname << ")";
|
||||||
|
|
||||||
//The list of paths to the folders in which to search for images
|
//The list of paths to the folders in which to search for images
|
||||||
|
@ -168,14 +168,14 @@ void PictureLoader::processLoadQueue()
|
||||||
imgReader.setFileName(picsPaths.at(i));
|
imgReader.setFileName(picsPaths.at(i));
|
||||||
if (imgReader.read(&image)) {
|
if (imgReader.read(&image)) {
|
||||||
qDebug() << "Picture found on disk (set: " << setName << " card: " << correctedCardname << ")";
|
qDebug() << "Picture found on disk (set: " << setName << " card: " << correctedCardname << ")";
|
||||||
emit imageLoaded(ptl.getCard(), image);
|
emit imageLoaded(cardBeingLoaded.getCard(), image);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
imgReader.setFileName(picsPaths.at(i) + ".full");
|
imgReader.setFileName(picsPaths.at(i) + ".full");
|
||||||
if (imgReader.read(&image)) {
|
if (imgReader.read(&image)) {
|
||||||
qDebug() << "Picture.full found on disk (set: " << setName << " card: " << correctedCardname << ")";
|
qDebug() << "Picture.full found on disk (set: " << setName << " card: " << correctedCardname << ")";
|
||||||
emit imageLoaded(ptl.getCard(), image);
|
emit imageLoaded(cardBeingLoaded.getCard(), image);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,19 +183,21 @@ void PictureLoader::processLoadQueue()
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (picDownload) {
|
if (picDownload) {
|
||||||
qDebug() << "Picture NOT found, trying to download (set: " << setName << " card: " << correctedCardname << ")";
|
qDebug() << "Picture NOT found, trying to download (set: " << setName << " card: " << correctedCardname << ")";
|
||||||
cardsToDownload.append(ptl);
|
cardsToDownload.append(cardBeingLoaded);
|
||||||
|
cardBeingLoaded=0;
|
||||||
if (!downloadRunning)
|
if (!downloadRunning)
|
||||||
startNextPicDownload();
|
startNextPicDownload();
|
||||||
} else {
|
} else {
|
||||||
if (ptl.nextSet())
|
if (cardBeingLoaded.nextSet())
|
||||||
{
|
{
|
||||||
qDebug() << "Picture NOT found and download disabled, moving to next set (newset: " << setName << " card: " << correctedCardname << ")";
|
qDebug() << "Picture NOT found and download disabled, moving to next set (newset: " << setName << " card: " << correctedCardname << ")";
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
loadQueue.prepend(ptl);
|
loadQueue.prepend(cardBeingLoaded);
|
||||||
|
cardBeingLoaded=0;
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Picture NOT found, download disabled, no more sets to try: BAILING OUT (oldset: " << setName << " card: " << correctedCardname << ")";
|
qDebug() << "Picture NOT found, download disabled, no more sets to try: BAILING OUT (oldset: " << setName << " card: " << correctedCardname << ")";
|
||||||
emit imageLoaded(ptl.getCard(), QImage());
|
emit imageLoaded(cardBeingLoaded.getCard(), QImage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,6 +341,16 @@ void PictureLoader::loadImage(CardInfo *card)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
|
// avoid queueing the same card more than once
|
||||||
|
if(card == cardBeingLoaded.getCard() || card == cardBeingDownloaded.getCard())
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach(PictureToLoad pic, loadQueue)
|
||||||
|
{
|
||||||
|
if(pic.getCard() == card)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
loadQueue.append(PictureToLoad(card));
|
loadQueue.append(PictureToLoad(card));
|
||||||
emit startLoadQueue();
|
emit startLoadQueue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ private:
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
QNetworkAccessManager *networkManager;
|
QNetworkAccessManager *networkManager;
|
||||||
QList<PictureToLoad> cardsToDownload;
|
QList<PictureToLoad> cardsToDownload;
|
||||||
|
PictureToLoad cardBeingLoaded;
|
||||||
PictureToLoad cardBeingDownloaded;
|
PictureToLoad cardBeingDownloaded;
|
||||||
bool picDownload, picDownloadHq, downloadRunning, loadQueueRunning;
|
bool picDownload, picDownloadHq, downloadRunning, loadQueueRunning;
|
||||||
void startNextPicDownload();
|
void startNextPicDownload();
|
||||||
|
|
Loading…
Reference in a new issue