examples: Dont try to load pixmaps from URLs

Change-Id: Idd4e01509077c27d2bd1569566788710e99d9539
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-07-29 10:03:06 +02:00
parent a02d3c7b52
commit c27c36a64b

View File

@@ -516,10 +516,10 @@ void ExamplesListModel::updateExamples()
QPixmap ExamplesListModel::fetchPixmapAndUpdatePixmapCache(const QString &url) const QPixmap ExamplesListModel::fetchPixmapAndUpdatePixmapCache(const QString &url) const
{ {
QPixmap pixmap; QPixmap pixmap;
pixmap.load(url); if (QPixmapCache::find(url, &pixmap))
if (pixmap.isNull()) return pixmap;
pixmap.load(resourcePath() + "/welcomescreen/widgets/" + url);
if (pixmap.isNull()) { if (url.startsWith("qthelp://")) {
QByteArray fetchedData = Core::HelpManager::fileData(url); QByteArray fetchedData = Core::HelpManager::fileData(url);
if (!fetchedData.isEmpty()) { if (!fetchedData.isEmpty()) {
QBuffer imgBuffer(&fetchedData); QBuffer imgBuffer(&fetchedData);
@@ -531,11 +531,18 @@ QPixmap ExamplesListModel::fetchPixmapAndUpdatePixmapCache(const QString &url) c
// boundedTo -> don't scale thumbnails up // boundedTo -> don't scale thumbnails up
const QSize scaledSize = ListModel::defaultImageSize.boundedTo(img.size()) * dpr; const QSize scaledSize = ListModel::defaultImageSize.boundedTo(img.size()) * dpr;
pixmap = QPixmap::fromImage( pixmap = QPixmap::fromImage(
img.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); img.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
pixmap.setDevicePixelRatio(dpr); pixmap.setDevicePixelRatio(dpr);
} }
} else {
pixmap.load(url);
if (pixmap.isNull())
pixmap.load(resourcePath() + "/welcomescreen/widgets/" + url);
} }
QPixmapCache::insert(url, pixmap); QPixmapCache::insert(url, pixmap);
return pixmap; return pixmap;
} }