From 02ed7f77f77fe5690143188767d0ead1be8bdf48 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Mon, 9 Sep 2024 15:59:35 +0300 Subject: [PATCH] QmlDesigner: Handle absolute and web urls when exporting a bundle Properly handle absolute paths: added to the root of the exported bundle. Skip web urls for now (they are not working for textures anyway) Change-Id: I4bb9e8bfbe28bd2a11b36ca1e1dae876dc9bce22 Reviewed-by: Miikka Heikkinen --- .../components/componentcore/bundlehelper.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp b/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp index c49e4746bf1..cd1f84c62ea 100644 --- a/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/bundlehelper.cpp @@ -660,9 +660,24 @@ QSet BundleHelper::getComponentDependencies(const Utils::FilePath &fi if (std::string_view{pValue.typeName()} == "QUrl") { QString pValueStr = pValue.toString(); if (!pValueStr.isEmpty() && !pValueStr.startsWith("#")) { - Utils::FilePath assetPath = filePath.parentDir().resolvePath(pValueStr); - Utils::FilePath assetPathRelative = assetPath.relativePathFrom(mainCompDir); - depList.insert({mainCompDir, assetPathRelative.toFSPathString()}); + Utils::FilePath pValuePath = Utils::FilePath::fromString(pValueStr); + Utils::FilePath assetPathBase; + QString assetPathRelative; + + if (!pValuePath.toUrl().isLocalFile() || pValuePath.startsWith("www.")) { + qWarning() << "BundleHelper::getComponentDependencies(): Web urls are not" + " supported. Skipping " << pValuePath; + continue; + } else if (pValuePath.isAbsolutePath()) { + assetPathRelative = pValuePath.fileName(); + assetPathBase = pValuePath.parentDir(); + } else { + Utils::FilePath assetPath = filePath.parentDir().resolvePath(pValueStr); + assetPathRelative = assetPath.relativePathFrom(mainCompDir).toFSPathString(); + assetPathBase = mainCompDir; + } + + depList.insert({assetPathBase, assetPathRelative}); } } }