Commit 02e1b869 authored by dt's avatar dt
Browse files

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
parent 8e11d1d1
......@@ -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();
......
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