diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-08-22 17:00:59 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-08-22 17:07:36 +0300 |
commit | e6f3d8b3e1158ebdc89ceae1de5ce7bc5c420f51 (patch) | |
tree | 197389a2268b472a19119fa3faf1f9ab1223240a /source/blender/editors | |
parent | eae9b86297876d2172681e880fe2bcc8450a01ed (diff) |
Revert "Fix T68971: Copy As New Driver from Material node creates a bad reference."
This reverts commits 54fd8176d7e91, 4c5becb6b1 and 8f578150e.
Those kind of commits must be reviewed and approved by project owners.
That one:
* Broke Collada building by not properly updating all calls to modified
function.
* Broke *whole* ID management by not properly updating library_query.c.
And in general, I am strongly against backward ID pointers, those are
*always* a serious PITA for ID management. Sometimes they cannot be
avoided, but in general other ways to get that kind of info should be
investigated first.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/drivers.c | 30 | ||||
-rw-r--r-- | source/blender/editors/include/ED_keyframing.h | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_group.c | 4 |
6 files changed, 10 insertions, 45 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index bf2056a7ec6..e341a16378c 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -846,36 +846,6 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) /* -------------------------------------------------- */ -/** Compute an ID pointer and path to property valid for use in a driver. - * Corrects for ID references that are not independent (e.g. material NodeTree). */ -bool ANIM_get_target_ID_and_path_to_property( - PointerRNA *ptr, PropertyRNA *prop, int index, ID **r_id, char **r_path) -{ - int dim = RNA_property_array_dimension(ptr, prop, NULL); - char *path = RNA_path_from_ID_to_property_index(ptr, prop, dim, index); - ID *id = ptr->id.data; - - if (!path) { - return false; - } - - if (GS(id->name) == ID_NT) { - bNodeTree *node_tree = (bNodeTree *)id; - - if (node_tree->owner) { - id = node_tree->owner; - - char *new_path = BLI_sprintfN("node_tree%s%s", path[0] == '[' ? "" : ".", path); - MEM_freeN(path); - path = new_path; - } - } - - *r_id = id; - *r_path = path; - return true; -} - /* Create a driver & variable that reads the specified property, * and store it in the buffers for Paste Driver and Paste Variables. */ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name) diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 455337b9cc0..bbeeeade822 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -403,11 +403,6 @@ bool ANIM_driver_vars_paste(struct ReportList *reports, struct FCurve *fcu, bool /* -------- */ -/** Compute an ID pointer and path to property valid for use in a driver. - * Corrects for ID references that are not independent (e.g. material NodeTree). */ -bool ANIM_get_target_ID_and_path_to_property( - struct PointerRNA *ptr, struct PropertyRNA *prop, int index, struct ID **r_id, char **r_path); - /* Create a driver & variable that reads the specified property, * and store it in the buffers for Paste Driver and Paste Variables. */ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index f8df8966297..c7ce66cfcf6 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -195,11 +195,11 @@ static int copy_as_driver_button_exec(bContext *C, wmOperator *UNUSED(op)) UI_context_active_but_prop_get(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - ID *id; - char *path; + int dim = RNA_property_array_dimension(&ptr, prop, NULL); + char *path = RNA_path_from_ID_to_property_index(&ptr, prop, dim, index); - if (ANIM_get_target_ID_and_path_to_property(&ptr, prop, index, &id, &path)) { - ANIM_copy_as_driver(id, path, RNA_property_identifier(prop)); + if (path) { + ANIM_copy_as_driver(ptr.id.data, path, RNA_property_identifier(prop)); MEM_freeN(path); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 5ee1925fd55..01a30f677a3 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -509,7 +509,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ntree = ntreeAddTree(bmain, treename, idname, NULL); + ntree = ntreeAddTree(bmain, treename, idname); /* hook into UI */ UI_context_active_but_prop_get_templateID(C, &ptr, &prop); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 46dfa65e73c..d31256a1425 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -448,7 +448,7 @@ void ED_node_shader_default(const bContext *C, ID *id) int output_type, shader_type; float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}, strength = 1.0f; - ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname, id); + ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname); switch (GS(id->name)) { case ID_MA: { @@ -534,7 +534,7 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) return; } - sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname, &sce->id); + sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname); sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; @@ -572,7 +572,7 @@ void ED_node_texture_default(const bContext *C, Tex *tx) return; } - tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname, &tx->id); + tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname); out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT); out->locx = 300.0f; diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 303cd39abba..3fd03bac874 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -644,7 +644,7 @@ static bool node_group_make_test_selected(bNodeTree *ntree, int ok = true; /* make a local pseudo node tree to pass to the node poll functions */ - ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname, NULL); + ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname); /* check poll functions for selected nodes */ for (node = ntree->nodes.first; node; node = node->next) { @@ -953,7 +953,7 @@ static bNode *node_group_make_from_selected(const bContext *C, } /* new nodetree */ - ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype, NULL); + ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype); /* make group node */ gnode = nodeAddNode(C, ntree, ntype); |