MCU: Fix missing files in list of project files

MCU projects contain subnodes for the contents of QmlProject files, which
get populated after the project tree was already added to the tree.

To make sure that the added files are also listed in
`Project::files(...)`, and therefore be considered for e.g. Locator and
project searches, the code must trigger `Project::handleSubTreeChanged`,
so the cached list of nodes is updated. This doesn't happen with
`addNode` (which is for construction before the tree is added to the
`ProjectTree`), and forcing the `ProjectTree::emitSubtreeChanged` signal
is also not sufficient.

Use `FolderNode::replaceSubtree` which was made for this usecase and
triggers all the relevant code.

Fixes: QTCREATORBUG-29297
Change-Id: I3a1c4c1aebf978e2788de905231b83355db75030
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Yasser Grimes <yasser.grimes@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2023-07-11 11:08:34 +02:00
parent b5fa6be362
commit 409591e6f9

View File

@@ -89,9 +89,7 @@ void updateMCUProjectTree(ProjectExplorer::Project *p)
auto qmlProjectNode = std::make_unique<McuQmlProjectNode>(FilePath(node->filePath()),
inputsJsonFile);
auto qmlProjectNodePtr = qmlProjectNode.get();
const_cast<ProjectNode *>(node)->addNode(std::move(qmlProjectNode));
ProjectExplorer::ProjectTree::emitSubtreeChanged(qmlProjectNodePtr);
const_cast<ProjectNode *>(node)->replaceSubtree(nullptr, std::move(qmlProjectNode));
});
};