From 58eb0d7967c8402fc021d316f525ddef0f4bad38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 15 Oct 2011 11:55:09 +0000 Subject: keep particle system names unique --- source/blender/makesrna/intern/rna_particle.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/makesrna/intern/rna_particle.c') diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index f0f782fede2..49005e56367 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -505,6 +505,17 @@ static int rna_PartSettings_is_fluid_get(PointerRNA *ptr) return part->type == PART_FLUID; } +void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value) +{ + Object *ob= ptr->id.data; + ParticleSystem *part= (ParticleSystem*)ptr->data; + + /* copy the new name into the name slot */ + BLI_strncpy_utf8(part->name, value, sizeof(part->name)); + + BLI_uniquename(&ob->particlesystem, part, "ParticleSystem", '.', offsetof(ParticleSystem, name), sizeof(part->name)); +} + static PointerRNA rna_ParticleSystem_active_particle_target_get(PointerRNA *ptr) { ParticleSystem *psys= (ParticleSystem*)ptr->data; @@ -2617,6 +2628,7 @@ static void rna_def_particle_system(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Particle system name"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER|NA_RENAME, NULL); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ParticleSystem_name_set"); RNA_def_struct_name_property(srna, prop); /* access to particle settings is redirected through functions */ -- cgit v1.2.3