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
path: root/source
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-05-14 12:38:04 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-05-14 12:39:36 +0300
commit1c106e189aafe235ca5e83c97ce477c80ccc437a (patch)
tree263ffa89f81fae9bf70106d9fdfcd3be199b4891 /source
parent02e3bf22ab6059db03c856f1d34b27a24ef8ec31 (diff)
RNA: fix the id_data pointer of PoseBone.bone to point at the Armature.
The owning ID reference of RNA pointers is supposed to point at the ID container that owns the object, but for PoseBone.bone it wasn't updated to point at the Armature data ID instead of Armature Object. This caused issues, like pose_bone.bone.driver_add() adding the driver to the Armature Object animation data, which violates the intended design of the animation data structures. Since RNA code generally assumes that all pointers that don't refer directly to an ID remain within the current ID, a custom getter is required to fix this.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 7babbbdc8c7..2f7f8c70760 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -289,6 +289,18 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
ED_armature_bone_rename(G_MAIN, ob->data, oldname, newname);
}
+static PointerRNA rna_PoseChannel_bone_get(PointerRNA *ptr)
+{
+ Object *ob = (Object *)ptr->id.data;
+ bPoseChannel *pchan = (bPoseChannel *)ptr->data;
+ PointerRNA tmp_ptr = *ptr;
+
+ /* Replace the id_data pointer with the Armature ID. */
+ tmp_ptr.id.data = ob->data;
+
+ return rna_pointer_inherit_refine(&tmp_ptr, &RNA_Bone, pchan->bone);
+}
+
static bool rna_PoseChannel_has_ik_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
@@ -916,6 +928,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "bone", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "Bone");
+ RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_bone_get", NULL, NULL, NULL);
RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Bone", "Bone associated with this PoseBone");