diff options
| author | Jeff Heller <jeffrey_heller@yahoo.com> | 2026-10-01 13:48:01 -0600 |
|---|---|---|
| committer | Jeff Heller <jeffrey_heller@yahoo.com> | 2026-10-02 15:36:15 +0000 |
| commit | 861a8762665baffc6b739704194d5a47e4110c71 (patch) | |
| tree | 78b7135386c64e39eb98420eab41e44f82036314 /src | |
| parent | bac9da45c9ec7927bde3b0a2b4dc7ed1fc3f032e (diff) | |
QQmlJSUtils: Accept a relative path in qmlSourcePathFromBuildPath()
qmlSourcePathFromBuildPath() found the module through a clean absolute
form of the path, then cut the module's absolute directory off the path
as passed in. qmllint passes the linted file's path as given on its
command line, so linting a build-folder copy by a relative path with
--resource read past the end of the string and crashed, for example:
cd build && qmllint --resource .qt/rcc/qmake_Mod.qrc \
--resource .qt/rcc/Mod_raw_qml_0.qrc Mod/Main.qml
Cut the module directory off the clean absolute path instead.
Pick-to: 6.12
Assisted-by: Claude Code
Change-Id: I92c078e7c45274b1eeb61c648d64514430cee817
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmlcompiler/qqmljsutils.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljsutils.cpp b/src/qmlcompiler/qqmljsutils.cpp index 7fc31e9524..baa5d7cea0 100644 --- a/src/qmlcompiler/qqmljsutils.cpp +++ b/src/qmlcompiler/qqmljsutils.cpp @@ -322,12 +322,13 @@ QString qmlSourcePathFromBuildPath(const QQmlJSResourceFileMapper *mapper, if (!mapper) return pathInBuildFolder; - const auto qmlModuleEntry = - qmlModuleEntryFromBuildPath(mapper, pathInBuildFolder, LocalFileFilter); + // Slice the path the mapper matched against: its entries are absolute and clean. + const QString buildPath = QDir::cleanPath(QFileInfo(pathInBuildFolder).absoluteFilePath()); + const auto qmlModuleEntry = qmlModuleEntryFromBuildPath(mapper, buildPath, LocalFileFilter); if (!qmlModuleEntry.isValid()) return pathInBuildFolder; const QString qrcPath = qmlModuleEntry.resourcePath - + QStringView(pathInBuildFolder).sliced(qmlModuleEntry.filePath.size()); + + QStringView(buildPath).sliced(qmlModuleEntry.filePath.size()); const auto entry = mapper->entry(QQmlJSResourceFileMapper::resourceFileFilter(qrcPath)); return entry.isValid()? entry.filePath : pathInBuildFolder; |
