Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-12-23 01:45:41 +0300
committerHans Goudey <h.goudey@me.com>2021-12-23 01:45:41 +0300
commitdca5be9b942ab03037910e87548375baa09f0068 (patch)
treee4d1cfc0a8da67a8d537de3e0abbdb8d0d9a4f84 /source/blender/nodes
parent14621e7720da31aaff4d1eec29886b69077569ba (diff)
Fix: Wrong node link drag search menu items for attribute statistic
Caused by capturing local variables by reference in a function that outlives the scope it was created in. Also use a more generic function for the first two inputs.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
index b79125d43d1..e4f2e8ef7f4 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
@@ -132,16 +132,13 @@ static std::optional<CustomDataType> node_type_from_other_socket(const bNodeSock
static void node_gather_link_searches(GatherLinkSearchOpParams &params)
{
const bNodeType &node_type = params.node_type();
+ const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
+ search_link_ops_for_declarations(params, declaration.inputs().take_front(2));
+
const std::optional<CustomDataType> type = node_type_from_other_socket(params.other_socket());
if (params.in_out() == SOCK_IN) {
- if (params.other_socket().type == SOCK_GEOMETRY) {
- params.add_item(IFACE_("Geometry"), [node_type](LinkSearchOpParams &params) {
- bNode &node = params.add_node(node_type);
- params.connect_available_socket(node, "Geometry");
- });
- }
if (type) {
- params.add_item(IFACE_("Attribute"), [&](LinkSearchOpParams &params) {
+ params.add_item(IFACE_("Attribute"), [node_type, type](LinkSearchOpParams &params) {
bNode &node = params.add_node(node_type);
node.custom1 = *type;
params.update_and_connect_available_socket(node, "Attribute");
@@ -149,9 +146,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams &params)
}
}
else if (type) {
- /* Only use the first 8 declarations since we set the type automatically. */
- const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
- for (const SocketDeclarationPtr &socket_decl : declaration.outputs().take_front(8)) {
+ for (const SocketDeclarationPtr &socket_decl : declaration.outputs()) {
StringRefNull name = socket_decl->name();
params.add_item(IFACE_(name.c_str()), [node_type, name, type](LinkSearchOpParams &params) {
bNode &node = params.add_node(node_type);