From 503e2c46a56f44e974dc04f567bd94548d537307 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Mon, 6 Jan 2025 11:14:27 +0200 Subject: [PATCH] Fix: Compositor crash with group of different typed socket The compositor crashes if a node inside a node group is connected to a group input that have a different type and the node group is used without a connection to that input. That's because the compositor code assumes the type of the group input without implicit type conversion to the expected type of the node. To fix this, handle implicit conversion for unconnected sockets as well. --- .../COM_multi_function_procedure_operation.hh | 4 +-- .../multi_function_procedure_operation.cc | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/blender/compositor/COM_multi_function_procedure_operation.hh b/source/blender/compositor/COM_multi_function_procedure_operation.hh index 73ac06d9375..24c0384fbec 100644 --- a/source/blender/compositor/COM_multi_function_procedure_operation.hh +++ b/source/blender/compositor/COM_multi_function_procedure_operation.hh @@ -88,12 +88,12 @@ class MultiFunctionProcedureOperation : public PixelOperation { mf::Variable *get_multi_function_input_variable(DInputSocket input_socket, DOutputSocket output_socket); - /* Implicitly convert the type of the given variable that is passed from the given output socket + /* Implicitly convert the type of the given variable that is passed from the given origin socket * to the given input socket if needed. This is done by adding an implicit conversion function * whose output variable will be returned. If no conversion is needed, the given variable is * returned as is. */ mf::Variable *do_variable_implicit_conversion(DInputSocket input_socket, - DOutputSocket output_socket, + DSocket origin_socket, mf::Variable *variable); /* Given the variables that were returned by calling the multi-function for the given node, diff --git a/source/blender/compositor/intern/multi_function_procedure_operation.cc b/source/blender/compositor/intern/multi_function_procedure_operation.cc index f498d853297..d60783e6ccb 100644 --- a/source/blender/compositor/intern/multi_function_procedure_operation.cc +++ b/source/blender/compositor/intern/multi_function_procedure_operation.cc @@ -187,27 +187,27 @@ Vector MultiFunctionProcedureOperation::get_input_variables(DNod const DSocket origin = get_input_origin_socket(input); if (origin->is_input()) { input_variables.append(this->get_constant_input_variable(DInputSocket(origin))); - continue; - } - - /* Otherwise, the origin socket is an output, which means it is linked. */ - const DOutputSocket output = DOutputSocket(origin); - - /* If the origin node is part of the multi-function procedure operation, then the output has an - * existing variable for it. */ - if (compile_unit_.contains(output.node())) { - input_variables.append(output_to_variable_map_.lookup(output)); } else { - /* Otherwise, the origin node is not part of the multi-function procedure operation, and a - * variable that represents an input to the multi-function procedure operation is used. */ - input_variables.append(this->get_multi_function_input_variable(input, output)); + /* Otherwise, the origin socket is an output, which means it is linked. */ + const DOutputSocket output = DOutputSocket(origin); + + /* If the origin node is part of the multi-function procedure operation, then the output has + * an existing variable for it. */ + if (compile_unit_.contains(output.node())) { + input_variables.append(output_to_variable_map_.lookup(output)); + } + else { + /* Otherwise, the origin node is not part of the multi-function procedure operation, and a + * variable that represents an input to the multi-function procedure operation is used. */ + input_variables.append(this->get_multi_function_input_variable(input, output)); + } } /* Implicitly convert the variable type if needed by adding a call to an implicit conversion * function. */ input_variables.last() = this->do_variable_implicit_conversion( - input, output, input_variables.last()); + input, origin, input_variables.last()); } return input_variables; @@ -418,10 +418,10 @@ static mf::MultiFunction *get_conversion_function(const ResultType variable_type } mf::Variable *MultiFunctionProcedureOperation::do_variable_implicit_conversion( - DInputSocket input_socket, DOutputSocket output_socket, mf::Variable *variable) + DInputSocket input_socket, DSocket origin_socket, mf::Variable *variable) { const ResultType expected_type = get_node_socket_result_type(input_socket.bsocket()); - const ResultType variable_type = get_node_socket_result_type(output_socket.bsocket()); + const ResultType variable_type = get_node_socket_result_type(origin_socket.bsocket()); const mf::MultiFunction *function = get_conversion_function(variable_type, expected_type); if (!function) {