diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index a2e19a427ed7e5e57c2ee483a774dde52fa24b10..a5b857c1dc37d3554464b89e29ee48847501f51e 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -576,9 +576,23 @@ bool Qt4PriFileNode::removeSubProjects(const QStringList &proFilePaths) bool Qt4PriFileNode::addFiles(const FileType fileType, const QStringList &filePaths, QStringList *notAdded) { - QStringList failedFiles; + // If a file is already referenced in the .pro file then we don't add them. + // That ignores scopes and which variable was used to reference the file + // So it's obviously a bit limited, but in those cases you need to edit the + // project files manually anyway. + + ProjectExplorer::FindAllFilesVisitor visitor; + accept(&visitor); + const QStringList &allFiles = visitor.filePaths(); + + QStringList uniqueFilePaths; + foreach (const QString &file, filePaths) { + if(!allFiles.contains(file)) + uniqueFilePaths.append(file); + } - changeFiles(fileType, filePaths, &failedFiles, AddToProFile); + QStringList failedFiles; + changeFiles(fileType, uniqueFilePaths, &failedFiles, AddToProFile); if (notAdded) *notAdded = failedFiles; return failedFiles.isEmpty();