diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 32976a99c50..c5c293f968d 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -322,10 +322,13 @@ void QbsProjectManagerPlugin::updateBuildActions() fileName = editorNode->filePath().fileName(); ProjectNode *parentProjectNode = editorNode->parentProjectNode(); + const QbsProductNode *productNode = nullptr; + for (const ProjectNode *potentialProductNode = parentProjectNode; + potentialProductNode && !productNode; + potentialProductNode = potentialProductNode->parentProjectNode()) { + productNode = dynamic_cast(potentialProductNode); + } - // FIXME: This code is wrong: If the file is in a Group, then productNode will be - // null and the action will be disabled. We have to walk up the tree. - auto productNode = dynamic_cast(parentProjectNode); if (productNode) { productVisible = true; productName = productNode->displayName();