[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51930] trunk/blender/source/blender/ makesrna/intern/rna_animation.c: Bugfix [#33043] Changing the name of a keying set does not change group name

Joshua Leung aligorith at gmail.com
Tue Nov 6 06:04:59 CET 2012


Revision: 51930
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51930
Author:   aligorith
Date:     2012-11-06 05:04:54 +0000 (Tue, 06 Nov 2012)
Log Message:
-----------
Bugfix [#33043] Changing the name of a keying set does not change group name

This now works for absolute Keying Sets (Builtin Keying Sets are highly context
dependent, and usually cannot be renamed, so this shouldn't be a problem there)

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_animation.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_animation.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_animation.c	2012-11-06 04:56:30 UTC (rev 51929)
+++ trunk/blender/source/blender/makesrna/intern/rna_animation.c	2012-11-06 05:04:54 UTC (rev 51930)
@@ -296,6 +296,43 @@
 
 /* ****************************** */
 
+static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value)
+{
+	KeyingSet *ks = (KeyingSet *)ptr->data;
+	
+	/* update names of corresponding groups if name changes */
+	if (strcmp(ks->name, value)) {
+		KS_Path *ksp;
+		
+		for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
+			if ((ksp->groupmode == KSP_GROUP_KSNAME) && (ksp->id)) {
+				AnimData *adt = BKE_animdata_from_id(ksp->id);
+				
+				/* TODO: NLA strips? */
+				if (adt && adt->action) {
+					bActionGroup *agrp;
+					
+					/* lazy check - should really find the F-Curve for the affected path and check its group 
+					 * but this way should be faster and work well for most cases, as long as there are no
+					 * conflicts
+					 */
+					for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) {
+						if (strcmp(ks->name, agrp->name) == 0) {
+							/* there should only be one of these in the action, so can stop... */
+							BLI_strncpy(agrp->name, value, sizeof(agrp->name));
+							break;
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	/* finally, update name to new value */
+	BLI_strncpy(ks->name, value, sizeof(ks->name));
+}
+
+
 static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr)
 {
 	KeyingSet *ks = (KeyingSet *)ptr->data;
@@ -721,19 +758,20 @@
 	srna = RNA_def_struct(brna, "KeyingSet", NULL);
 	RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together");
 	
-	/* Id/Label. */
+	/* Id/Label */
 	prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "idname");
 	RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
 	RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC);
-	RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
+/*	RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL); */ /* NOTE: disabled, as ID name shouldn't be editable */
 	
 	prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "name");
+	RNA_def_property_string_funcs(prop, NULL, NULL, "rna_KeyingSet_name_set");
 	RNA_def_property_ui_text(prop, "UI Name", "");
 	RNA_def_struct_ui_icon(srna, ICON_KEYINGSET);
 	RNA_def_struct_name_property(srna, prop);
-/*	RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/
+	RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET | NA_RENAME, NULL);
 	
 	prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
 	RNA_def_property_string_sdna(prop, NULL, "description");




More information about the Bf-blender-cvs mailing list