Screenshots: do not retry image thumbnailing on null result
This causes the thumbnailing thread pool to spend a lot of time attempting to retry an image that failed. A null result is common where the image is too large to be allocated (>128MiB alloc). The repeated retries continue after page delete, causing hangs if a user tries to exit the application. Fixes: #1201 Signed-off-by: James Beddek <telans@posteo.de>
This commit is contained in:
parent
f2471f0f68
commit
75bd626f33
@ -96,37 +96,30 @@ public:
|
|||||||
return;
|
return;
|
||||||
if ((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
|
if ((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
|
||||||
return;
|
return;
|
||||||
int tries = 5;
|
if (!m_cache->stale(m_path))
|
||||||
while (tries)
|
return;
|
||||||
{
|
QImage image(m_path);
|
||||||
if (!m_cache->stale(m_path))
|
if (image.isNull()) {
|
||||||
return;
|
m_resultEmitter.emitResultsFailed(m_path);
|
||||||
QImage image(m_path);
|
qDebug() << "Error loading screenshot: " + m_path + ". Perhaps too large?";
|
||||||
if (image.isNull())
|
|
||||||
{
|
|
||||||
QThread::msleep(500);
|
|
||||||
tries--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
QImage small;
|
|
||||||
if (image.width() > image.height())
|
|
||||||
small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
|
|
||||||
else
|
|
||||||
small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
|
|
||||||
QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
|
|
||||||
QImage square(QSize(256, 256), QImage::Format_ARGB32);
|
|
||||||
square.fill(Qt::transparent);
|
|
||||||
|
|
||||||
QPainter painter(&square);
|
|
||||||
painter.drawImage(offset, small);
|
|
||||||
painter.end();
|
|
||||||
|
|
||||||
QIcon icon(QPixmap::fromImage(square));
|
|
||||||
m_cache->add(m_path, icon);
|
|
||||||
m_resultEmitter.emitResultsReady(m_path);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_resultEmitter.emitResultsFailed(m_path);
|
QImage small;
|
||||||
|
if (image.width() > image.height())
|
||||||
|
small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
|
||||||
|
else
|
||||||
|
small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
|
||||||
|
QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
|
||||||
|
QImage square(QSize(256, 256), QImage::Format_ARGB32);
|
||||||
|
square.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter painter(&square);
|
||||||
|
painter.drawImage(offset, small);
|
||||||
|
painter.end();
|
||||||
|
|
||||||
|
QIcon icon(QPixmap::fromImage(square));
|
||||||
|
m_cache->add(m_path, icon);
|
||||||
|
m_resultEmitter.emitResultsReady(m_path);
|
||||||
}
|
}
|
||||||
QString m_path;
|
QString m_path;
|
||||||
SharedIconCachePtr m_cache;
|
SharedIconCachePtr m_cache;
|
||||||
|
Loading…
Reference in New Issue
Block a user