From e318ecd81dc55492d3647c5e7c289fe9c0e839eb Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 26 Feb 2019 16:35:47 +0100 Subject: [PATCH] Qbs: Simplify updateBuildActions() Now that the sub-project cases are gone, part of the logic are dead. Change-Id: I37d5bb7fe82ba5d8d2b064dd5231daf201ee6d67 Reviewed-by: Christian Kandeler --- .../qbsprojectmanagerplugin.cpp | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp index 5a09c5b6716..3cb1d45a85e 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerplugin.cpp @@ -314,32 +314,24 @@ void QbsProjectManagerPlugin::updateBuildActions() bool enabled = false; bool fileVisible = false; bool productVisible = false; - bool subprojectVisible = false; QString fileName; QString productName; - QString subprojectName; if (Node *editorNode = currentEditorNode()) { - QbsProject *editorProject = currentEditorProject(); - enabled = editorProject - && !BuildManager::isBuilding(editorProject) - && !editorProject->isParsing(); - fileName = editorNode->filePath().fileName(); - fileVisible = editorProject && editorNode && dynamic_cast(editorNode->parentProjectNode()); - auto productNode = - dynamic_cast(editorNode ? editorNode->parentProjectNode() : nullptr); + // 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(editorNode->parentProjectNode()); if (productNode) { productVisible = true; productName = productNode->displayName(); } - auto subprojectNode = - dynamic_cast(productNode ? productNode->parentFolderNode() : nullptr); - if (subprojectNode && editorProject && subprojectNode != editorProject->rootProjectNode()) { - subprojectVisible = true; - subprojectName = subprojectNode->displayName(); + + if (QbsProject *editorProject = currentEditorProject()) { + enabled = !BuildManager::isBuilding(editorProject) && !editorProject->isParsing(); + fileVisible = dynamic_cast(editorNode->parentProjectNode()); } }