Nodes: add versioning to set new optional label flag for existing menu sockets

Before this option existed, all menu sockets were drawn as if this setting was enabled.
This patch sets this flag by default for all menu sockets to avoid changing the drawing
of existing node group inputs.

Ref: #146939

Pull Request: https://projects.blender.org/blender/blender/pulls/147107
This commit is contained in:
Jacques Lucke
2025-10-01 11:23:25 +02:00
parent c627ea9aca
commit 96bb18de1e
2 changed files with 19 additions and 1 deletions

View File

@@ -27,7 +27,7 @@
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 96
#define BLENDER_FILE_SUBVERSION 97
/* 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

View File

@@ -3694,6 +3694,24 @@ void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 97)) {
/* Enable new "Optional Label" setting for all menu sockets. This was implicit before. */
FOREACH_NODETREE_BEGIN (bmain, tree, id) {
tree->tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
if (item.item_type != NODE_INTERFACE_SOCKET) {
return true;
}
auto &socket = reinterpret_cast<bNodeTreeInterfaceSocket &>(item);
if (!STREQ(socket.socket_type, "NodeSocketMenu")) {
return true;
}
socket.flag |= NODE_INTERFACE_SOCKET_OPTIONAL_LABEL;
return true;
});
}
FOREACH_NODETREE_END;
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.