From 409591e6f9accd837bbd13898636cc7b51468713 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 11 Jul 2023 11:08:34 +0200 Subject: [PATCH] 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: Reviewed-by: Yasser Grimes Reviewed-by: Christian Kandeler --- src/plugins/mcusupport/mcusupportplugin.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plugins/mcusupport/mcusupportplugin.cpp b/src/plugins/mcusupport/mcusupportplugin.cpp index f0726e3895f..05f457689d8 100644 --- a/src/plugins/mcusupport/mcusupportplugin.cpp +++ b/src/plugins/mcusupport/mcusupportplugin.cpp @@ -89,9 +89,7 @@ void updateMCUProjectTree(ProjectExplorer::Project *p) auto qmlProjectNode = std::make_unique(FilePath(node->filePath()), inputsJsonFile); - auto qmlProjectNodePtr = qmlProjectNode.get(); - const_cast(node)->addNode(std::move(qmlProjectNode)); - ProjectExplorer::ProjectTree::emitSubtreeChanged(qmlProjectNodePtr); + const_cast(node)->replaceSubtree(nullptr, std::move(qmlProjectNode)); }); };