Fix: Nodes: String node initialization regression with link-drag-search

I think the special handling for string input node, added in #139478,
was broken by #146033. The early check for src_value (`if (!src_value)`)
caused the string-specific logic to be skipped. This PR moves the
string-specific handling before the src_value check.

Pull Request: https://projects.blender.org/blender/blender/pulls/147697
This commit is contained in:
W_Cloud
2025-10-12 16:33:50 +02:00
committed by Hans Goudey
parent 2db54c43d8
commit ef58bd609b

View File

@@ -3752,6 +3752,17 @@ void node_socket_move_default_value(Main & /*bmain*/,
}
}
/* Special handling for strings because the generic code below can't handle them. */
if (src.type == SOCK_STRING && dst.type == SOCK_STRING &&
dst_node.is_type("FunctionNodeInputString"))
{
auto *src_value = static_cast<bNodeSocketValueString *>(src.default_value);
auto *dst_storage = static_cast<NodeInputString *>(dst_node.storage);
MEM_SAFE_FREE(dst_storage->string);
dst_storage->string = BLI_strdup_null(src_value->value);
return;
}
void *src_value = socket_value_storage(src);
if (!src_value) {
return;
@@ -3768,17 +3779,6 @@ void node_socket_move_default_value(Main & /*bmain*/,
return;
}
/* Special handling for strings because the generic code below can't handle them. */
if (src.type == SOCK_STRING && dst.type == SOCK_STRING &&
dst_node.is_type("FunctionNodeInputString"))
{
auto *src_value = static_cast<bNodeSocketValueString *>(src.default_value);
auto *dst_storage = static_cast<NodeInputString *>(dst_node.storage);
MEM_SAFE_FREE(dst_storage->string);
dst_storage->string = BLI_strdup_null(src_value->value);
return;
}
void *dst_value = node_static_value_storage_for(dst_node, dst);
if (!dst_value) {
return;