Pass the absolute path with the file when finding files

When generating a project, the directories can be specified as arguments
to the qmake call. As a result files can either be incorrectly added to
the project with a leading slash, or can end up duplicated. By passing
the absolute path with the file, it ensures that the file is added
correctly and no duplicates occur as a result.

Task-number: QTBUG-48342
Change-Id: If774de8d7f5cceca80042a25a3aa4e5b045249da
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Andy Shaw 2017-06-13 15:10:30 +02:00
parent a232251992
commit b2cb83ecbb

View File

@ -118,14 +118,15 @@ ProjectGenerator::init()
dir = regex.left(s+1); dir = regex.left(s+1);
regex = regex.right(regex.length() - (s+1)); regex = regex.right(regex.length() - (s+1));
} }
const QDir d(dir);
if (Option::recursive) { if (Option::recursive) {
QStringList entries = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList entries = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i = 0; i < entries.count(); i++) for (int i = 0; i < entries.count(); i++)
dirs.append(dir + entries[i] + QDir::separator() + regex); dirs.append(dir + entries[i] + QDir::separator() + regex);
} }
QStringList files = QDir(dir).entryList(QDir::nameFiltersFromString(regex)); QStringList files = d.entryList(QDir::nameFiltersFromString(regex));
for(int i = 0; i < (int)files.count(); i++) { for(int i = 0; i < (int)files.count(); i++) {
QString file = dir + files[i]; QString file = d.absoluteFilePath(files[i]);
if (addFile(file)) { if (addFile(file)) {
add_depend = true; add_depend = true;
file_count++; file_count++;