From ffaba40eabacd6679da05dabcbdf4e9ffa9b9d59 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Thu, 20 Jun 2024 17:17:09 +0300 Subject: [PATCH] QmlDesigner: Fix icon generation dependencies missing in content lib Change-Id: I07641feaa55d8b8c374c3e9e6efdce2e1dcc9246 Reviewed-by: Miikka Heikkinen --- .../contentlibrary/contentlibraryview.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp index c3a662d63cd..a08eb6cd678 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp @@ -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(); 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);