Fix #106208: data-block socket defaults not used for node group #107179

Merged
Jacques Lucke merged 5 commits from JacquesLucke/blender:node-group-default-id into main 2023-04-20 22:27:58 +02:00
2 changed files with 6 additions and 1 deletions
Showing only changes of commit 6a48b05f63 - Show all commits

View File

@ -158,7 +158,11 @@ class StringBuilder : public SocketDeclarationBuilder<String> {
class IDSocketDeclaration : public SocketDeclaration {
public:
const char *idname;
/** Get the default ID pointer for this socket. This is a function to avoid dangling pointers. */
/**

Maybe add , since bNode::idpointers are remapped asID pointers change, but pointers in socket declarations are not managed the same way.

Maybe add `, since `bNode::id` pointers are remapped as `ID` pointers change, but pointers in socket declarations are not managed the same way.`
* Get the default ID pointer for this socket. This is a function to avoid dangling pointers,
* since bNode::id pointers are remapped as ID pointers change, but pointers in socket
* declarations are not managed the same way.
*/
std::function<ID *(const bNode &node)> default_value_fn;
public:

View File

@ -140,6 +140,7 @@ static std::function<ID *(const bNode &node)> get_default_id_getter(const bNodeT
const bNodeTree &ntree = *reinterpret_cast<const bNodeTree *>(node.id);
const bNodeSocket *io_socket;
if (in_out == SOCK_IN) {
/* Better be save than sorry when the underlying node group changed. */

Hmm, why would the socket index be out of bounds here? Does this function object live past some changes to the group interface? If so, maybe worth noting that in a comment.

Hmm, why would the socket index be out of bounds here? Does this function object live past some changes to the group interface? If so, maybe worth noting that in a comment.

The problem is, I don't think we know for sure how long this will live currently. At least I don't know.

The problem is, I don't think we know for sure how long this will live currently. At least I don't know.

save -> safe

`save` -> `safe`
if (socket_index < ntree.interface_inputs().size()) {
io_socket = ntree.interface_inputs()[socket_index];
}