From 02e1b8694b57ba3ce65acc7f76a4c541fe891bd3 Mon Sep 17 00:00:00 2001 From: dt Date: Tue, 18 May 2010 16:29:41 +0200 Subject: [PATCH] Check if the file is already used in the .pro file. And refuse to add it twice. The check is pretty simplistic in that it doesn't take scopes or which variable it's exactly in into account. But in those cases you need to edit the .pro file manually anyway. Task-Nr: QTCREATORBUG-932 Task-Nr: QTCREATORBUG-891 Task-Nr: QTCREATORBUG-653 --- src/plugins/qt4projectmanager/qt4nodes.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index a2e19a427ed..a5b857c1dc3 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. - changeFiles(fileType, filePaths, &failedFiles, AddToProFile); + ProjectExplorer::FindAllFilesVisitor visitor; + accept(&visitor); + const QStringList &allFiles = visitor.filePaths(); + + QStringList uniqueFilePaths; + foreach (const QString &file, filePaths) { + if(!allFiles.contains(file)) + uniqueFilePaths.append(file); + } + + QStringList failedFiles; + changeFiles(fileType, uniqueFilePaths, &failedFiles, AddToProFile); if (notAdded) *notAdded = failedFiles; return failedFiles.isEmpty();