[Bf-blender-cvs] [416e66c7fe2] master: Fix ShaderNodeCustomGroup.copy method being called too often

Brecht Van Lommel noreply at git.blender.org
Sat Dec 7 20:43:09 CET 2019


Commit: 416e66c7fe211e7e21d0d4fad987d4219c191f71
Author: Brecht Van Lommel
Date:   Sat Dec 7 19:35:52 2019 +0100
Branches: master
https://developer.blender.org/rB416e66c7fe211e7e21d0d4fad987d4219c191f71

Fix ShaderNodeCustomGroup.copy method being called too often

This is only supposed to happen when copying nodes that are part of the user
editable database, not temporary copies for the dependency graph.

The LIB_ID_COPY_LOCALIZE test was wrong because it is a combination of multiple
bitflags as pointed out by Bastien, and was actually redundant anyway since
LIB_ID_CREATE_NO_MAIN is part of it.

===================================================================

M	source/blender/blenkernel/intern/node.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/nodes/shader/node_shader_tree.c

===================================================================

diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 779728cb037..578d81b157c 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1146,8 +1146,9 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree, const bNode *node_src, const int flag)
 
   node_dst->new_node = NULL;
 
-  bool do_copy_api = !((flag & LIB_ID_CREATE_NO_MAIN) || (flag & LIB_ID_COPY_LOCALIZE));
-  if (node_dst->typeinfo->copyfunc_api && do_copy_api) {
+  /* Only call copy function when a copy is made for the main database, not
+   * for cases like the dependency graph and localization. */
+  if (node_dst->typeinfo->copyfunc_api && !(flag & LIB_ID_CREATE_NO_MAIN)) {
     PointerRNA ptr;
     RNA_pointer_create((ID *)ntree, &RNA_Node, node_dst, &ptr);
 
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 8811918b552..9623d89e030 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2064,7 +2064,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
       /* No ID refcounting, this node is virtual,
        * detached from any actual Blender data currently. */
       bNode *new_node = BKE_node_copy_store_new_pointers(
-          NULL, node, LIB_ID_CREATE_NO_USER_REFCOUNT);
+          NULL, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN);
       BKE_node_clipboard_add_node(new_node);
     }
   }
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 4bcd77496c1..ffeeb7525d5 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -635,7 +635,8 @@ static bNode *ntree_shader_copy_branch(bNodeTree *ntree,
   LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
     if (node->tmp_flag >= 0) {
       int id = node->tmp_flag;
-      nodes_copy[id] = BKE_node_copy_ex(ntree, node, LIB_ID_CREATE_NO_USER_REFCOUNT);
+      nodes_copy[id] = BKE_node_copy_ex(
+          ntree, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN);
       nodes_copy[id]->tmp_flag = -2; /* Copy */
       /* Make sure to clear all sockets links as they are invalid. */
       LISTBASE_FOREACH (bNodeSocket *, sock, &nodes_copy[id]->inputs) {



More information about the Bf-blender-cvs mailing list