Fix T89260: Eevee crashes with custom node sockets.

Cause of this issue is that Custom Node Sockets info type was
initialized as SOCK_FLOAT when registering. Areas within the core that
would ignore custom socket types by checking its type would use the
socket as being a float type.

When custom node sockets have a property called default_value blender
tries to store it as an internal default value what failed in debug
builds.

This patch will set the socket type to SOCK_CUSTOM when registering a
custom socket type and allow, but skip storage of custom default values.
In this case the default values should already be stored as custom
properies.

Reviewed By: campbellbarton, JacquesLucke

Maniphest Tasks: T89260

Differential Revision: https://developer.blender.org/D13174
This commit is contained in:
Jeroen Bakker 2021-11-15 08:07:11 +01:00 committed by Jeroen Bakker
parent 622e6f05f1
commit a5c59fb90e
Notes: blender-bot 2023-02-14 11:34:30 +01:00
Referenced by commit 85df7036f7, Fix T94827: Group Input/Output cannot connect to custom sockets
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #94827, Regression: Group Input/Output cannot connect to some custom sockets
Referenced by issue #89260, Eevee instant crash with a custom node from template example
2 changed files with 4 additions and 1 deletions

View File

@ -474,8 +474,10 @@ static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *so
case SOCK_MATERIAL:
BLO_write_struct(writer, bNodeSocketValueMaterial, sock->default_value);
break;
case __SOCK_MESH:
case SOCK_CUSTOM:
/* Custom node sockets where default_value is defined uses custom properties for storage. */
break;
case __SOCK_MESH:
case SOCK_SHADER:
case SOCK_GEOMETRY:
BLI_assert_unreachable();

View File

@ -2805,6 +2805,7 @@ static StructRNA *rna_NodeSocket_register(Main *UNUSED(bmain),
/* setup dummy socket & socket type to store static properties in */
memset(&dummyst, 0, sizeof(bNodeSocketType));
dummyst.type = SOCK_CUSTOM;
memset(&dummysock, 0, sizeof(bNodeSocket));
dummysock.typeinfo = &dummyst;