Nodes: ensure that node identifiers are larger than zero
Zero should not be a valid identifier to make it easier to detect when the identifier has not been set after a node has been allocated.
This commit is contained in:
parent
39615cd3b7
commit
88c6d824e7
Notes:
blender-bot
2024-01-16 18:05:25 +01:00
Referenced by commit 2bce3c0ac4
, Fix: don't allow node identifiers to be zero
|
@ -2192,7 +2192,7 @@ void nodeUniqueID(bNodeTree *ntree, bNode *node)
|
|||
|
||||
/* In the unlikely case that the random ID doesn't match, choose a new one until it does. */
|
||||
int32_t new_id = id_rng.get_int32();
|
||||
while (ntree->runtime->nodes_by_id.contains_as(new_id)) {
|
||||
while (ntree->runtime->nodes_by_id.contains_as(new_id) || new_id <= 0) {
|
||||
new_id = id_rng.get_int32();
|
||||
}
|
||||
|
||||
|
|
|
@ -1013,7 +1013,7 @@ class NodeTreeMainUpdater {
|
|||
/* Check the uniqueness of node identifiers. */
|
||||
Set<int32_t> node_identifiers;
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
|
||||
BLI_assert(node->identifier >= 0);
|
||||
BLI_assert(node->identifier > 0);
|
||||
node_identifiers.add_new(node->identifier);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue