[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37199] trunk/blender/source/blender: fix [#27554] vertex group names

Campbell Barton ideasman42 at gmail.com
Sun Jun 5 06:52:33 CEST 2011


Revision: 37199
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37199
Author:   campbellbarton
Date:     2011-06-05 04:52:32 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
fix [#27554] vertex group names
- duplicate vertex group names were not being checked for.
- also made the first duplicate end with .001 rather than .000

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c	2011-06-05 03:48:49 UTC (rev 37198)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c	2011-06-05 04:52:32 UTC (rev 37199)
@@ -153,8 +153,10 @@
 int BLI_split_name_num(char *left, int *nr, const char *name, const char delim)
 {
 	int a;
-	
-	*nr= 0;
+
+	/* could use '0', but this would mean the first
+	 * duplicate would become FooBar.000 */
+	*nr= 1;
 	a= strlen(name);
 	memcpy(left, name, (a + 1) * sizeof(char));
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c	2011-06-05 03:48:49 UTC (rev 37198)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c	2011-06-05 04:52:32 UTC (rev 37199)
@@ -454,6 +454,14 @@
 		BKE_report(NULL, RPT_ERROR, "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
 }
 
+void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
+{
+	Object *ob= (Object *)ptr->id.data;
+	bDeformGroup *dg= (bDeformGroup *)ptr->data;
+	BLI_strncpy(dg->name, value, sizeof(dg->name));
+	defgroup_unique_name(dg, ob);
+}
+
 static int rna_VertexGroup_index_get(PointerRNA *ptr)
 {
 	Object *ob= (Object*)ptr->id.data;
@@ -1236,6 +1244,7 @@
 	prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Name", "Vertex group name");
 	RNA_def_struct_name_property(srna, prop);
+	RNA_def_property_string_funcs(prop, NULL, NULL, "rna_VertexGroup_name_set");
 	RNA_def_property_update(prop, NC_GEOM|ND_DATA|NA_RENAME, "rna_Object_internal_update_data"); /* update data because modifiers may use [#24761] */
 
 	prop= RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);




More information about the Bf-blender-cvs mailing list