Fix #112439: Don't allow hiding sockets of Reroute node

Reroute node consists only of a socket, it has no body.
Don't allow hiding sockets of reroutes anymore, since it could make the
node invisible or prevent links from being connected to it.

The versioning ensures that the sockets on reroute nodes are not hidden.

Pull Request: https://projects.blender.org/blender/blender/pulls/112965
This commit is contained in:
Iliya Katueshenock 2023-09-27 18:42:46 +02:00 committed by Hans Goudey
parent 48204b630c
commit 462010c61a
4 changed files with 28 additions and 1 deletions

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */ /* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION #define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 28 #define BLENDER_FILE_SUBVERSION 29
/* Minimum Blender version that supports reading file written with the current /* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to * version. Older Blender versions will test this and cancel loading the file, showing a warning to

@ -1546,6 +1546,19 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
} }
} }
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 29)) {
/* Unhide all Reroute nodes. */
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->is_reroute()) {
static_cast<bNodeSocket *>(node->inputs.first)->flag &= ~SOCK_HIDDEN;
static_cast<bNodeSocket *>(node->outputs.first)->flag &= ~SOCK_HIDDEN;
}
}
}
FOREACH_NODETREE_END;
}
/** /**
* Versioning code until next subversion bump goes here. * Versioning code until next subversion bump goes here.
* *

@ -1102,6 +1102,11 @@ bool node_has_hidden_sockets(bNode *node)
void node_set_hidden_sockets(bNode *node, int set) void node_set_hidden_sockets(bNode *node, int set)
{ {
/* The Reroute node is the socket itself, do not hide this. */
if (node->is_reroute()) {
return;
}
if (set == 0) { if (set == 0) {
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
sock->flag &= ~SOCK_HIDDEN; sock->flag &= ~SOCK_HIDDEN;

@ -293,6 +293,15 @@ static void rna_NodeSocket_hide_set(PointerRNA *ptr, bool value)
return; return;
} }
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(ptr->owner_id);
bNode *node;
nodeFindNode(ntree, sock, &node, nullptr);
/* The Reroute node is the socket itself, do not hide this. */
if (node->is_reroute()) {
return;
}
if (value) { if (value) {
sock->flag |= SOCK_HIDDEN; sock->flag |= SOCK_HIDDEN;
} }