QmlDesigner: Fix asset images becoming invalid after delete + recreate

The problem was that, for "invalid assets" (i.e. pixmaps of assets that
could not be read / did not exist on disk), the "default" thumbnail was
saved in the cache -- and thus, when the asset re-appeared on disk, the
"default" (invalid) thumbnail was shown.

Task-number: QDS-8591
Change-Id: Iec2f3e704c1deef2e7a7c75532518639fdc677e5
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Samuel Ghinet
2022-12-15 17:50:23 +02:00
parent f9ecc8b57a
commit aaf2e6f0f7

View File

@@ -25,13 +25,17 @@ QPixmap AssetsLibraryIconProvider::requestPixmap(const QString &id, QSize *size,
pixmap = m_thumbnails[id]; pixmap = m_thumbnails[id];
} else { } else {
pixmap = fetchPixmap(id, requestedSize); pixmap = fetchPixmap(id, requestedSize);
if (pixmap.isNull()) bool haveValidImage = true;
if (pixmap.isNull()) {
pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/assets_default.png"); pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/assets_default.png");
haveValidImage = false;
}
if (requestedSize.isValid()) if (requestedSize.isValid())
pixmap = pixmap.scaled(requestedSize, Qt::KeepAspectRatio); pixmap = pixmap.scaled(requestedSize, Qt::KeepAspectRatio);
m_thumbnails[id] = pixmap; if (haveValidImage)
m_thumbnails[id] = pixmap;
} }
if (size) { if (size) {