summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Köhne <kai.koehne@qt.io>2023-01-03 11:22:30 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-06 10:26:05 +0000
commitdf67d9bc4151fa63a8ee07aebd2bfb699fbab803 (patch)
treea2ee6d931d72701decfe5a902aab7c21cf371503
parentbc8cd52f4558e44acbb45b422069c912dedca741 (diff)
downloadqttools-df67d9bc4151fa63a8ee07aebd2bfb699fbab803.tar.gz
qtattributionsscanner: Do not get stuck for invalid Path
Do check early on that the Path directory actually exists, and print a warning if not. Change-Id: I4a09182820f809e2f004101886d2f6ee0515dbd6 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 39fdcb8e7a366ecea74c90bc86dc8c2068ae5bce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qtattributionsscanner/scanner.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/qtattributionsscanner/scanner.cpp b/src/qtattributionsscanner/scanner.cpp
index 703c9db00..20666c71e 100644
--- a/src/qtattributionsscanner/scanner.cpp
+++ b/src/qtattributionsscanner/scanner.cpp
@@ -77,16 +77,25 @@ static bool validatePackage(Package &p, const QString &filePath, LogLevel logLev
}
const QDir dir = p.path;
- for (const QString &file : std::as_const(p.files)) {
- if (!dir.exists(file)) {
- if (logLevel != SilentLog) {
- std::cerr << qPrintable(tr("File %1: Path '%2' does not exist in directory '%3'.")
- .arg(QDir::toNativeSeparators(filePath),
- QDir::toNativeSeparators(file),
- QDir::toNativeSeparators(p.path)))
- << std::endl;
+ if (!dir.exists()) {
+ std::cerr << qPrintable(
+ tr("File %1: Directory '%2' does not exist.")
+ .arg(QDir::toNativeSeparators(filePath), QDir::toNativeSeparators(p.path)))
+ << std::endl;
+ validPackage = false;
+ } else {
+ for (const QString &file : std::as_const(p.files)) {
+ if (!dir.exists(file)) {
+ if (logLevel != SilentLog) {
+ std::cerr << qPrintable(
+ tr("File %1: Path '%2' does not exist in directory '%3'.")
+ .arg(QDir::toNativeSeparators(filePath),
+ QDir::toNativeSeparators(file),
+ QDir::toNativeSeparators(p.path)))
+ << std::endl;
+ }
+ validPackage = false;
}
- validPackage = false;
}
}
@@ -142,11 +151,12 @@ static QString locateLicensesDir(const QString &packageDir)
static const QString licensesSubDir = u"LICENSES"_s;
QDir dir(packageDir);
while (true) {
+ if (!dir.exists())
+ break;
if (dir.cd(licensesSubDir))
return dir.path();
- if (dir.isRoot())
+ if (dir.isRoot() || !dir.cdUp())
break;
- dir.cdUp();
}
return {};
}