Fix inconsistent creation of NodeTreeTypeUndefined type of node tree
Currently, when creating a new node tree ID, its `typeinfo` is set to `NodeTreeTypeUndefined`, but its `type` enum value is left to `0`, aka `NTREE_SHADER`. This patch adds a new `NTREE_UNDIFINED` value, and use it for `NodeTreeTypeUndefined` types of node trees. NOTE: While it is not clear whether that actually fixes issues currently, quite a bit of code still relies on the value of `type`, so think it makes sense to sanitize this. NOTE: Would have been ideal to reserve `0` value to undefined type, but at this point this is not possible anymore, so chose to use `-2` instead. Reviewed By: JacquesLucke Differential Revision: https://developer.blender.org/D13123
This commit is contained in:
@@ -1160,15 +1160,15 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo)
|
||||
{
|
||||
if (typeinfo) {
|
||||
ntree->typeinfo = typeinfo;
|
||||
|
||||
/* deprecated integer type */
|
||||
ntree->type = typeinfo->type;
|
||||
}
|
||||
else {
|
||||
ntree->typeinfo = &NodeTreeTypeUndefined;
|
||||
|
||||
ntree->init &= ~NTREE_TYPE_INIT;
|
||||
}
|
||||
|
||||
/* Deprecated integer type. */
|
||||
ntree->type = ntree->typeinfo->type;
|
||||
}
|
||||
|
||||
static void node_set_typeinfo(const struct bContext *C,
|
||||
@@ -5533,6 +5533,7 @@ static void register_undefined_types()
|
||||
* they are just used as placeholders in case the actual types are not registered.
|
||||
*/
|
||||
|
||||
NodeTreeTypeUndefined.type = NTREE_UNDEFINED;
|
||||
strcpy(NodeTreeTypeUndefined.idname, "NodeTreeUndefined");
|
||||
strcpy(NodeTreeTypeUndefined.ui_name, N_("Undefined"));
|
||||
strcpy(NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type"));
|
||||
|
||||
Reference in New Issue
Block a user