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:
authorJoshua Leung <aligorith@gmail.com>2009-10-20 07:44:35 +0400
committerJoshua Leung <aligorith@gmail.com>2009-10-20 07:44:35 +0400
commit7f133f65b2049546adddec77720c90aafb9add97 (patch)
treec7ebbb8eb317f0dea27f9f338debe9e1f49035d6 /source/blender/makesrna/intern/rna_key.c
parent9e6d1c6cfaf5e06d734a2a1124bd4ee3c030fd38 (diff)
Bugfix #19663: Renaming named data doesn't fix F-Curves
RNA Paths used in F-Curve, Drivers, etc. now get renamed when some data that they use gets renamed. This only works when things like Bones, Constraints, Shape Keys, and Modifiers get renamed, but other cases can get added easily. The code here only performs simple string replacements, so there is the potential for problems when several sets of data with the same names are present. For example, if there are multiple armatures with bones that have the same names, renaming a bone on one armature (with a bone on another armature having the same name) will break all the drivers on the other one, even though they aren't really connected. However, I don't expect the aforementioned scenario to really be a problem in most production scenarios.
Diffstat (limited to 'source/blender/makesrna/intern/rna_key.c')
-rw-r--r--source/blender/makesrna/intern/rna_key.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 230ed90c131..1e1eb9b055f 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -37,6 +37,8 @@
#ifdef RNA_RUNTIME
+#include <stddef.h>
+
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -47,6 +49,27 @@
#include "WM_api.h"
#include "WM_types.h"
+void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value)
+{
+ KeyBlock *kb= ptr->data;
+ char oldname[32];
+
+ /* make a copy of the old name first */
+ BLI_strncpy(oldname, kb->name, sizeof(oldname));
+
+ /* copy the new name into the name slot */
+ BLI_strncpy(kb->name, value, sizeof(kb->name));
+
+ /* make sure the name is truly unique */
+ if (ptr->id.data) {
+ Key *key= ptr->id.data;
+ BLI_uniquename(&key->block, kb, "Key", '.', offsetof(KeyBlock, name), 32);
+ }
+
+ /* fix all the animation data which may link to this */
+ BKE_all_animdata_fix_paths_rename("keys", oldname, kb->name);
+}
+
static void rna_ShapeKey_value_set(PointerRNA *ptr, float value)
{
KeyBlock *data= (KeyBlock*)ptr->data;
@@ -353,6 +376,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShapeKey_name_set");
RNA_def_struct_name_property(srna, prop);
/* keys need to be sorted to edit this */