aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-04-25 11:40:05 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2018-05-08 05:14:05 +0000
commitc4e4bb9604a884ca5966ebab19e510a1966f798a (patch)
tree85aa8cd95a41b611dfd56d7cb574b471109d2b8a
parentf58f1b0b4e1b417c7f32b08ad59ad4b67f5f4e3a (diff)
Prevent empty strings in qbsSearchPaths1.11
As QFileInfo::canonicalFilePath might return an empty string, we must remove all empty strings from the result of makePathsCanonical. All other search path handling code is not prepared for handling empty strings. This fixes ---snip--- SOFT ASSERT: isAbsolute(base, hostOs) && !isCurrentDrivePath(rel, hostOs) in ../../../../master/src/lib/corelib/tools/fileinfo.cpp:192 base: , rel: qbs/base ---snap--- we would get when having a non-existent path in qbsSearchPaths. Change-Id: I62c3c1054fd762b521005ab8da08b194148428b4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/lib/corelib/language/itemreader.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/corelib/language/itemreader.cpp b/src/lib/corelib/language/itemreader.cpp
index 22f4ff11c..578f194bc 100644
--- a/src/lib/corelib/language/itemreader.cpp
+++ b/src/lib/corelib/language/itemreader.cpp
@@ -50,10 +50,15 @@
namespace qbs {
namespace Internal {
-void makePathsCanonical(QStringList &paths)
+static void makePathsCanonical(QStringList &paths)
{
- for (QString &p : paths)
+ auto it = std::remove_if(paths.begin(), paths.end(), [](QString &p) {
p = QFileInfo(p).canonicalFilePath();
+ return p.isEmpty();
+ });
+ auto e = paths.end();
+ if (it != e)
+ paths.erase(it, e);
}
ItemReader::ItemReader(Logger &logger) : m_visitorState(new ItemReaderVisitorState(logger))