1
1

Docs: add comments to bNodeType init & free callbacks

When investigating ID user-count issues, it wasn't clear how nodes
were meant to handle user-count for ID's. Specifically that the
initfunc should _not_ increment the ID's user count.
This commit is contained in:
2023-03-07 15:08:32 +11:00
parent 90dc655951
commit 0e64d1e652
2 changed files with 18 additions and 3 deletions

View File

@@ -271,9 +271,20 @@ typedef struct bNodeType {
/** Check and update if internal ID data has changed. */
void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node);
/** Initialize a new node instance of this type after creation. */
/**
* Initialize a new node instance of this type after creation.
*
* \note Assignments to `node->id` must not increment the user of the ID.
* This is handled by the caller of this callback.
*/
void (*initfunc)(struct bNodeTree *ntree, struct bNode *node);
/** Free the node instance. */
/**
* Free the node instance.
*
* \note Access to `node->id` must be avoided in this function as this is called
* while freeing #Main, the state of this ID is undefined.
* Higher level logic to remove the node handles the user-count.
*/
void (*freefunc)(struct bNode *node);
/** Make a copy of the node instance. */
void (*copyfunc)(struct bNodeTree *dest_ntree,

View File

@@ -330,7 +330,11 @@ typedef struct bNode {
int16_t custom1, custom2;
float custom3, custom4;
/** Optional link to libdata. */
/**
* Optional link to libdata.
*
* \see #bNodeType::initfunc & #bNodeType::freefunc for details on ID user-count.
*/
struct ID *id;
/** Custom data struct for node properties for storage in files. */