Fix T66290: new Node's init api callback was not handling ID usercount.

As Usual...

Note that we have to edit each C-defined of those callbacks that set
Node->id pointer, instead of just moving the generic call to
`id_us_plus()` in `node_init()` below the call to
`ntype->initfunc_api()`, since that one manipulates RNA pointers, which
are supposed to already handle usercounts themselves on assignment.

The C callbacks are moving back to manipulating directly DNA, so it's
their responsability to handle user count then (Py code should do that
automatically through RNA assignement).
This commit is contained in:
2019-07-02 15:08:16 +02:00
parent 163996b681
commit 71099a3d67
5 changed files with 11 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_scene.h"
@@ -514,6 +515,7 @@ static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr)
int sock_index = 0;
node->id = &scene->id;
id_us_plus(node->id);
for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next, sock_index++) {
NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");

View File

@@ -24,6 +24,7 @@
#include "node_composite_util.h"
#include "BKE_context.h"
#include "BKE_library.h"
static bNodeSocketTemplate cmp_node_movieclip_out[] = {
{SOCK_RGBA, 0, N_("Image")},
@@ -42,6 +43,7 @@ static void init(const bContext *C, PointerRNA *ptr)
MovieClipUser *user = MEM_callocN(sizeof(MovieClipUser), "node movie clip user");
node->id = (ID *)scene->clip;
id_us_plus(node->id);
node->storage = user;
user->framenr = 1;
}

View File

@@ -24,6 +24,7 @@
#include "node_composite_util.h"
#include "BKE_context.h"
#include "BKE_library.h"
/* **************** Translate ******************** */
@@ -53,6 +54,7 @@ static void init(const bContext *C, PointerRNA *ptr)
Scene *scene = CTX_data_scene(C);
node->id = (ID *)scene->clip;
id_us_plus(node->id);
}
static void storage_free(bNode *node)

View File

@@ -24,6 +24,7 @@
#include "node_composite_util.h"
#include "BKE_context.h"
#include "BKE_library.h"
/* **************** Translate ******************** */
@@ -43,6 +44,7 @@ static void init(const bContext *C, PointerRNA *ptr)
Scene *scene = CTX_data_scene(C);
node->id = (ID *)scene->clip;
id_us_plus(node->id);
/* default to bilinear, see node_sampler_type_items in rna_nodetree.c */
node->custom1 = 1;

View File

@@ -23,6 +23,8 @@
*/
#include "BKE_context.h"
#include "BKE_library.h"
#include "../node_composite_util.h"
/* **************** SWITCH VIEW ******************** */
@@ -122,6 +124,7 @@ static void init_switch_view(const bContext *C, PointerRNA *ptr)
/* store scene for updates */
node->id = (ID *)scene;
id_us_plus(node->id);
if (scene) {
RenderData *rd = &scene->r;