aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-07-31 13:00:11 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-07-31 11:32:47 +0000
commit530e8568b170a9be5ae7bcdc443b741a8c2e44e0 (patch)
tree949fb5401a8b3f16ea48804bc386c879c9ae7714
parentc24320123b2abd74657d33ce58c099f46f21c50e (diff)
OutputFormatter: Fix linkification of relative file paths
If we encounter a relative file path that can map to more than one absolute file path, we do not linkify it, as that would be misleading. However, we forgot to check whether the "different" candidates are really different. For example, consider the following situation: - We have a header file /usr/include/header.h. - This file shows up in the compile output as "../header.h". - At that time, we have two search dirs /usr/include/libA and /usr/include/libB. - This resulted in two candidate file paths /usr/include/libA/../header.h and /usr/include/libB/../header.h - The relative path was rejected as ambiguous. Fix this by checking for duplicates when gathering candidates. Change-Id: I139b848d938113f1b5a959d8043411f7f3e809be Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/libs/utils/outputformatter.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp
index 5650e1fa88..34c76d3ce6 100644
--- a/src/libs/utils/outputformatter.cpp
+++ b/src/libs/utils/outputformatter.cpp
@@ -140,12 +140,15 @@ FilePath OutputLineParser::absoluteFilePath(const FilePath &filePath)
return filePath;
FilePaths candidates;
for (const FilePath &dir : searchDirectories()) {
- const FilePath candidate = dir.pathAppended(filePath.toString());
- if (candidate.exists() || d->skipFileExistsCheck)
- candidates << candidate;
+ FilePath candidate = dir.pathAppended(filePath.toString());
+ if (candidate.exists() || d->skipFileExistsCheck) {
+ candidate = FilePath::fromString(QDir::cleanPath(candidate.toString()));
+ if (!candidates.contains(candidate))
+ candidates << candidate;
+ }
}
if (candidates.count() == 1)
- return FilePath::fromString(QDir::cleanPath(candidates.first().toString()));
+ return candidates.first();
QString fp = filePath.toString();
while (fp.startsWith("../"))