From dd47ee9e25e2faff2582ea4cb1cd11efec33e2ac Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 12 May 2025 16:13:57 +0200 Subject: [PATCH] Nodes: show warning when a group output is unused There are very rare use-cases for having multiple Group Output nodes. However, it's something that's been supported for a long time and removing it may be a regression for some. In practice, it's usually a mistake when someone has multiple Group Output nodes. This patch adds a simple warning on inactive Group Output nodes to help the user notice this case. Pull Request: https://projects.blender.org/blender/blender/pulls/138743 --- .../blender/editors/space_node/node_draw.cc | 2 +- source/blender/nodes/NOD_node_extra_info.hh | 1 + source/blender/nodes/intern/node_common.cc | 22 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index cc3f3336221..32179ae04b8 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -3070,7 +3070,7 @@ static Vector node_get_extra_info(const bContext &C, Vector rows; if (node.typeinfo->get_extra_info) { - nodes::NodeExtraInfoParams params{rows, node, C}; + nodes::NodeExtraInfoParams params{rows, *snode.edittree, node, C}; node.typeinfo->get_extra_info(params); } diff --git a/source/blender/nodes/NOD_node_extra_info.hh b/source/blender/nodes/NOD_node_extra_info.hh index 10c777bd350..69c4c7ee58d 100644 --- a/source/blender/nodes/NOD_node_extra_info.hh +++ b/source/blender/nodes/NOD_node_extra_info.hh @@ -22,6 +22,7 @@ struct NodeExtraInfoRow { struct NodeExtraInfoParams { Vector &rows; + const bNodeTree &tree; const bNode &node; const bContext &C; }; diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index b0f16b81707..4f17eb656b1 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -33,10 +33,14 @@ #include "NOD_common.hh" #include "NOD_node_declaration.hh" +#include "NOD_node_extra_info.hh" #include "NOD_register.hh" #include "NOD_socket.hh" #include "NOD_socket_declarations.hh" #include "NOD_socket_declarations_geometry.hh" + +#include "UI_resources.hh" + #include "node_common.h" #include "node_util.hh" @@ -875,6 +879,23 @@ bNodeSocket *node_group_output_find_socket(bNode *node, const StringRef identifi return nullptr; } +static void node_group_output_extra_info(blender::nodes::NodeExtraInfoParams ¶ms) +{ + const blender::Span group_output_nodes = params.tree.nodes_by_type( + "NodeGroupOutput"); + if (group_output_nodes.size() <= 1) { + return; + } + if (params.node.flag & NODE_DO_OUTPUT) { + return; + } + blender::nodes::NodeExtraInfoRow row; + row.text = IFACE_("Unused Output"); + row.icon = ICON_ERROR; + row.tooltip = TIP_("There are multiple group output nodes and this one is not active"); + params.rows.append(std::move(row)); +} + void register_node_type_group_output() { /* used for all tree types, needs dynamic allocation */ @@ -889,6 +910,7 @@ void register_node_type_group_output() blender::bke::node_type_size(*ntype, 140, 80, 400); ntype->declare = blender::nodes::group_output_declare; ntype->insert_link = blender::nodes::group_output_insert_link; + ntype->get_extra_info = node_group_output_extra_info; ntype->no_muting = true;