Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-06-03 18:08:25 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-06-04 10:34:35 +0300
commitb998a7b384c6a598ea851fbc06a2df8829c34329 (patch)
tree793596dbb9b642b26240f2629ee855b7301c3fec /source/blender/blenkernel/BKE_node.h
parent351e68e0a4de49912747d97b2e53ffcde45aeb53 (diff)
Fix T64247: Crash on playback with special shader node tree
The root of the problem goes to the fact that node tree copying uses source tree and nodes for a temporary storage. This makes it so multiple dependency graphs can not be reliably evaluated from different threads if they are using same original node tree. Solved by doing the following: - Commonly used tree copying function (which is used by library manager) keeps source tree, nodes and sockets untouched. - All the related areas (like node tree's callback) now have const qualifier on the input. - Areas which needs to have those temporary pointers assigned are now using explicit function. Would be really cool to get rid of those temporary pointers completely, but this is a bit tricky due to hairy nature of the code. Can happen any time now though: is easy enough to generalize the new pointers mapping. Note that this change is only intended to solve the crash. The fact that icons shouldn't be updated on playback will be fixed as a separate change. Reviewers: brecht, fclem Reviewed By: brecht, fclem Subscribers: brecht, fclem Differential Revision: https://developer.blender.org/D5002
Diffstat (limited to 'source/blender/blenkernel/BKE_node.h')
-rw-r--r--source/blender/blenkernel/BKE_node.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index b760be29dae..fb6096cd82f 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -225,12 +225,14 @@ typedef struct bNodeType {
/// Free the node instance.
void (*freefunc)(struct bNode *node);
/// Make a copy of the node instance.
- void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, struct bNode *src_node);
+ void (*copyfunc)(struct bNodeTree *dest_ntree,
+ struct bNode *dest_node,
+ const struct bNode *src_node);
/* Registerable API callback versions, called in addition to C callbacks */
void (*initfunc_api)(const struct bContext *C, struct PointerRNA *ptr);
void (*freefunc_api)(struct PointerRNA *ptr);
- void (*copyfunc_api)(struct PointerRNA *ptr, struct bNode *src_node);
+ void (*copyfunc_api)(struct PointerRNA *ptr, const struct bNode *src_node);
/* can this node type be added to a node tree */
bool (*poll)(struct bNodeType *ntype, struct bNodeTree *nodetree);
@@ -538,7 +540,20 @@ void nodeRemoveNode(struct Main *bmain,
struct bNode *node,
bool do_id_user);
-struct bNode *BKE_node_copy_ex(struct bNodeTree *ntree, struct bNode *node_src, const int flag);
+struct bNode *BKE_node_copy_ex(struct bNodeTree *ntree,
+ const struct bNode *node_src,
+ const int flag);
+
+/* Same as BKE_node_copy_ex() but stores pointers to a new node and its sockets in the source
+ * node.
+ *
+ * NOTE: DANGER ZONE!
+ *
+ * TODO(sergey): Maybe it's better to make BKE_node_copy_ex() return a mapping from old node and
+ * sockets to new one. */
+struct bNode *BKE_node_copy_store_new_pointers(struct bNodeTree *ntree,
+ struct bNode *node_src,
+ const int flag);
struct bNodeLink *nodeAddLink(struct bNodeTree *ntree,
struct bNode *fromnode,
@@ -730,7 +745,7 @@ void node_type_storage(struct bNodeType *ntype,
void (*freefunc)(struct bNode *node),
void (*copyfunc)(struct bNodeTree *dest_ntree,
struct bNode *dest_node,
- struct bNode *src_node));
+ const struct bNode *src_node));
void node_type_label(
struct bNodeType *ntype,
void (*labelfunc)(struct bNodeTree *ntree, struct bNode *, char *label, int maxlen));