ProjectExplorer: Treat empty root project nodes better

Do not set up empty root project nodes and fall back to the default
project tree instead. A project can not ever be empty: It should at
least include the project file itself so that the user can fix
breakages when project parsing fails.

Change-Id: I692e299f56727305120777cdc532607d5b0be99e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-03-24 11:06:26 +01:00
parent 3492da1246
commit b021660c1e

View File

@@ -461,6 +461,14 @@ void Project::setRootProjectNode(ProjectNode *root)
if (d->m_rootProjectNode == root)
return;
if (root && root->nodes().isEmpty()) {
// Something went wrong with parsing: At least the project file needs to be
// shown so that the user can fix the breakage.
// Do not leak root and use default project tree in this case.
delete root;
root = nullptr;
}
ProjectTree::applyTreeManager(root);
ProjectNode *oldNode = d->m_rootProjectNode;