QmlDesigner: Fix icon generation dependencies missing in content lib

Change-Id: I07641feaa55d8b8c374c3e9e6efdce2e1dcc9246
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2024-06-20 17:17:09 +03:00
parent dad1232165
commit ffaba40eab

View File

@@ -879,13 +879,23 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
};
if (iconPixmap.isNull()) {
// copy qml to a temp folder as icon generation fails sometimes when generating directly from
// the bundle folder
// copy qml and its dependencies to a temp folder as icon generation fails sometimes when
// generating directly from the bundle folder
m_tempDir = std::make_unique<QTemporaryDir>();
QTC_ASSERT(m_tempDir->isValid(), return);
Utils::FilePath qmlPathTemp = Utils::FilePath::fromString(m_tempDir->path()).pathAppended(qml);
auto tempDirPath = Utils::FilePath::fromString(m_tempDir->path());
Utils::FilePath qmlPathTemp = tempDirPath.pathAppended(qml);
bundlePath.pathAppended(qml).copyFile(qmlPathTemp);
for (const QString &assetPath : depAssetsList) {
Utils::FilePath assetPathSource = DocumentManager::currentResourcePath().pathAppended(assetPath);
Utils::FilePath assetPathTarget = tempDirPath.pathAppended(assetPath);
assetPathTarget.parentDir().ensureWritableDir();
auto result = assetPathSource.copyFile(assetPathTarget);
QTC_ASSERT_EXPECTED(result,);
}
getImageFromCache(qmlPathTemp.toFSPathString(), saveIcon);
} else {
saveIcon(iconPixmap);