ProjectManagers: Avoid deletion of special files

Do not allow deletion or rename of files that are used
to define or manage projects.
This fixes issues of being able to remove or rename
pri and pro files of qmake based projects as well as
special files used by the GenericProjectManager.

Change-Id: Ib173abf04368f0625a9e481bb7290aa11933e62f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2019-07-18 10:43:05 +02:00
parent 4c6c3de53b
commit 53ca9752e2
2 changed files with 7 additions and 15 deletions

View File

@@ -217,17 +217,8 @@ static bool supportsNodeAction(ProjectAction action, const Node *node)
const QbsProject * const project = parentQbsProjectNode(node)->project();
if (!project->isProjectEditable())
return false;
auto equalsNodeFilePath = [node](const QString &str)
{
return str == node->filePath().toString();
};
if (action == RemoveFile || action == Rename) {
if (node->asFileNode())
return !Utils::contains(project->qbsProject().buildSystemFiles(), equalsNodeFilePath);
}
if (action == RemoveFile || action == Rename)
return node->asFileNode();
return false;
}