diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2024-08-09 13:15:24 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-08-13 22:59:14 +0000 |
| commit | 1852267f6349d222d48ab5b21dbc2938d5d282ee (patch) | |
| tree | 7adb8fc0c27e52615196610c675b7d3bbd848b32 | |
| parent | ce7303567f9d29ce9d9c55f4cd014afc8b805833 (diff) | |
qmlls: do not endless loop on _deps build folder
Add a missing NoDotAndDotdot flag to the entryInfoList() call to avoid
infinite looping on _deps folder.
Pick-to: 6.5
Task-number: QTBUG-123491
Change-Id: I3920ea67f49f51b612e4937403af2e5bec5eaad0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 8a8bfb410ad0f9c93fdcf2c7d04950444af5710b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit bdb2cc69e37aa48b2c4d7281fb43c6ad413a4e9b)
| -rw-r--r-- | src/qmlls/qqmlcodemodel.cpp | 4 | ||||
| -rw-r--r-- | tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/qmlls/qqmlcodemodel.cpp b/src/qmlls/qqmlcodemodel.cpp index c8003b1f00..3822280ca9 100644 --- a/src/qmlls/qqmlcodemodel.cpp +++ b/src/qmlls/qqmlcodemodel.cpp @@ -763,7 +763,7 @@ QStringList QQmlCodeModel::buildPathsForFileUrl(const QByteArray &url) QString dirName = d.dirName(); QDateTime lastModified; while (d.cdUp() && --iDir > 0) { - for (const QFileInfo &fInfo : d.entryInfoList(QDir::Dirs)) { + for (const QFileInfo &fInfo : d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { if (fInfo.completeBaseName() == u"build" || fInfo.completeBaseName().startsWith(u"build-%1"_s.arg(dirName))) { if (iDir > 1) @@ -786,7 +786,7 @@ QStringList QQmlCodeModel::buildPathsForFileUrl(const QByteArray &url) res += bPath; if (QFile::exists(bPath + u"/_deps") && bPath.split(u"/_deps/"_s).size() < maxDeps) { QDir d(bPath + u"/_deps"); - for (const QFileInfo &fInfo : d.entryInfoList(QDir::Dirs)) + for (const QFileInfo &fInfo : d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) buildPaths.append(fInfo.absoluteFilePath()); } } diff --git a/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp b/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp index e0045b0023..aede287bb0 100644 --- a/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp +++ b/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp @@ -32,6 +32,10 @@ void tst_qmlls_qqmlcodemodel::buildPathsForFileUrl_data() QTest::addRow("EnvironmentVariableOverridesIniFile") << path1 << path2 << QString() << path2; QTest::addRow("iniFile") << path1 << QString() << QString() << path1; QTest::addRow("environmentVariable") << QString() << path3 << QString() << path3; + + // bug where qmlls allocates memory in an endless loop because of a folder called "_deps" + QTest::addRow("endlessLoop") << QString() << QString() << testFile(u"buildfolderwithdeps"_s) + << testFile(u"buildfolderwithdeps"_s); } void tst_qmlls_qqmlcodemodel::buildPathsForFileUrl() |
