Fix #101615: node group pulls in unnecessary data-blocks when linked
The issue here was sometimes an output socket of a `Group Input` node has a reference to a data-block. The value stored on these output sockets are never used, and thus is not exposed in the UI which made it impossible for the user to find that there still is a data-block reference. The root cause for this seems to have been fixed a few releases ago. I can reproduce that the pointer was set in 3.3, but not in 3.6. This patch only adds some versioning to remove the unnecessary data-block references to fix old files that might have this issue (e.g. the file from the report). Pull Request: https://projects.blender.org/blender/blender/pulls/131900
This commit is contained in:
@@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 13
|
||||
#define BLENDER_FILE_SUBVERSION 14
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -3290,6 +3290,39 @@ static void version_node_locations_to_global(bNodeTree &ntree)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear unnecessary pointers to data blocks on output sockets group input nodes.
|
||||
* These values should never have been set in the first place. They are not harmful on their own,
|
||||
* but can pull in additional data-blocks when the node group is linked/appended.
|
||||
*/
|
||||
static void version_group_input_socket_data_block_reference(bNodeTree &ntree)
|
||||
{
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
|
||||
if (node->type != NODE_GROUP_INPUT) {
|
||||
continue;
|
||||
}
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
|
||||
switch (socket->type) {
|
||||
case SOCK_OBJECT:
|
||||
socket->default_value_typed<bNodeSocketValueObject>()->value = nullptr;
|
||||
break;
|
||||
case SOCK_IMAGE:
|
||||
socket->default_value_typed<bNodeSocketValueImage>()->value = nullptr;
|
||||
break;
|
||||
case SOCK_COLLECTION:
|
||||
socket->default_value_typed<bNodeSocketValueCollection>()->value = nullptr;
|
||||
break;
|
||||
case SOCK_TEXTURE:
|
||||
socket->default_value_typed<bNodeSocketValueTexture>()->value = nullptr;
|
||||
break;
|
||||
case SOCK_MATERIAL:
|
||||
socket->default_value_typed<bNodeSocketValueMaterial>()->value = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
{
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 1)) {
|
||||
@@ -5265,6 +5298,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 404, 14)) {
|
||||
LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
|
||||
version_group_input_socket_data_block_reference(*ntree);
|
||||
}
|
||||
}
|
||||
|
||||
/* Always run this versioning; meshes are written with the legacy format which always needs to
|
||||
* be converted to the new format on file load. Can be moved to a subversion check in a larger
|
||||
* breaking release. */
|
||||
|
||||
Reference in New Issue
Block a user