From 3a6adc0ed30be1d940f8069ad5e35bb27140ada6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 5 Jun 2011 04:52:32 +0000 Subject: [PATCH] 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 --- source/blender/blenlib/intern/path_util.c | 6 ++++-- source/blender/makesrna/intern/rna_object.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index e0a08d0b890..6106dca2633 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -153,8 +153,10 @@ void BLI_stringenc(char *string, const char *head, const char *tail, unsigned sh 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)); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9305380d06c..8ee8652e2e5 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -454,6 +454,14 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) 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 @@ static void rna_def_vertex_group(BlenderRNA *brna) 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);