Commit 005ca71c authored by Tim Jenssen's avatar Tim Jenssen

qmake: Use a QSet<FileName> for sets of folders

Change-Id: Ia2b9c435bd16eb5175534975fd822cecb74cc70f
Reviewed-by: default avatarhjk <hjk@qt.io>
parent f716aac5
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
class QmakePriFileEvalResult class QmakePriFileEvalResult
{ {
public: public:
QStringList folders; QSet<FileName> folders;
QSet<FileName> recursiveEnumerateFiles; QSet<FileName> recursiveEnumerateFiles;
QMap<FileType, QSet<FileName>> foundFiles; QMap<FileType, QSet<FileName>> foundFiles;
}; };
...@@ -229,7 +229,7 @@ bool QmakePriFile::buildsFile(const FileName &fn) const ...@@ -229,7 +229,7 @@ bool QmakePriFile::buildsFile(const FileName &fn) const
QmakePriFile::~QmakePriFile() QmakePriFile::~QmakePriFile()
{ {
watchFolders(QSet<QString>()); watchFolders( {} );
qDeleteAll(m_children); qDeleteAll(m_children);
} }
...@@ -310,26 +310,25 @@ void QmakePriFile::extractInstalls( ...@@ -310,26 +310,25 @@ void QmakePriFile::extractInstalls(
auto *result = proToResult.value(source.proFile); auto *result = proToResult.value(source.proFile);
if (!result) if (!result)
result = fallback; result = fallback;
result->folders << source.fileName; result->folders.insert(FileName::fromString(source.fileName));
} }
} }
} }
void QmakePriFile::processValues(QmakePriFileEvalResult &result) void QmakePriFile::processValues(QmakePriFileEvalResult &result)
{ {
result.folders.removeDuplicates();
// Remove non existing items and non folders // Remove non existing items and non folders
QStringList::iterator it = result.folders.begin(); auto it = result.folders.begin();
while (it != result.folders.end()) { while (it != result.folders.end()) {
QFileInfo fi(*it); QFileInfo fi((*it).toFileInfo());
if (fi.exists()) { if (fi.exists()) {
if (fi.isDir()) { if (fi.isDir()) {
result.recursiveEnumerateFiles += recursiveEnumerate((*it).toString());
// keep directories // keep directories
++it; ++it;
} else { } else {
// move files directly to recursiveEnumerateFiles // move files directly to recursiveEnumerateFiles
result.recursiveEnumerateFiles << FileName::fromString(*it); result.recursiveEnumerateFiles += (*it);
it = result.folders.erase(it); it = result.folders.erase(it);
} }
} else { } else {
...@@ -338,9 +337,6 @@ void QmakePriFile::processValues(QmakePriFileEvalResult &result) ...@@ -338,9 +337,6 @@ void QmakePriFile::processValues(QmakePriFileEvalResult &result)
} }
} }
foreach (const QString &folder, result.folders)
result.recursiveEnumerateFiles += recursiveEnumerate(folder);
for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i) { for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i) {
FileType type = static_cast<FileType>(i); FileType type = static_cast<FileType>(i);
QSet<FileName> &foundFiles = result.foundFiles[type]; QSet<FileName> &foundFiles = result.foundFiles[type];
...@@ -354,7 +350,7 @@ void QmakePriFile::processValues(QmakePriFileEvalResult &result) ...@@ -354,7 +350,7 @@ void QmakePriFile::processValues(QmakePriFileEvalResult &result)
void QmakePriFile::update(const Internal::QmakePriFileEvalResult &result) void QmakePriFile::update(const Internal::QmakePriFileEvalResult &result)
{ {
m_recursiveEnumerateFiles = result.recursiveEnumerateFiles; m_recursiveEnumerateFiles = result.recursiveEnumerateFiles;
watchFolders(result.folders.toSet()); watchFolders(result.folders);
for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i) { for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i) {
const FileType type = static_cast<FileType>(i); const FileType type = static_cast<FileType>(i);
...@@ -362,20 +358,20 @@ void QmakePriFile::update(const Internal::QmakePriFileEvalResult &result) ...@@ -362,20 +358,20 @@ void QmakePriFile::update(const Internal::QmakePriFileEvalResult &result)
} }
} }
void QmakePriFile::watchFolders(const QSet<QString> &folders) void QmakePriFile::watchFolders(const QSet<FileName> &folders)
{ {
const QSet<QString> folderStrings =
Utils::transform(folders, [] (const FileName &f) { return f.toString(); });
QSet<QString> toUnwatch = m_watchedFolders; QSet<QString> toUnwatch = m_watchedFolders;
toUnwatch.subtract(folders); toUnwatch.subtract(folderStrings);
QSet<QString> toWatch = folders; QSet<QString> toWatch = folderStrings;
toWatch.subtract(m_watchedFolders); toWatch.subtract(m_watchedFolders);
if (!toUnwatch.isEmpty()) m_project->unwatchFolders(toUnwatch.toList(), this);
m_project->unwatchFolders(toUnwatch.toList(), this); m_project->watchFolders(toWatch.toList(), this);
if (!toWatch.isEmpty())
m_project->watchFolders(toWatch.toList(), this);
m_watchedFolders = folders; m_watchedFolders = folderStrings;
} }
bool QmakePriFile::knowsFile(const FileName &filePath) const bool QmakePriFile::knowsFile(const FileName &filePath) const
......
...@@ -209,7 +209,7 @@ private: ...@@ -209,7 +209,7 @@ private:
Internal::QmakePriFileEvalResult *fallback, Internal::QmakePriFileEvalResult *fallback,
const InstallsList &installList); const InstallsList &installList);
static void processValues(Internal::QmakePriFileEvalResult &result); static void processValues(Internal::QmakePriFileEvalResult &result);
void watchFolders(const QSet<QString> &folders); void watchFolders(const QSet<Utils::FileName> &folders);
QmakeProject *m_project = nullptr; QmakeProject *m_project = nullptr;
QmakeProFile *m_qmakeProFile = nullptr; QmakeProFile *m_qmakeProFile = nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment