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:
authorCampbell Barton <ideasman42@gmail.com>2011-10-13 08:06:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-13 08:06:32 +0400
commit03c72a5ba0fd29542eced2276f63241d3b8cd572 (patch)
treebee3f945ba15fb2e156915f0cf0dceb49d89c0bd /source/blender/makesrna/intern
parent49b1a319c44f0ac3db45652f4cb022d2e1a93d40 (diff)
ensure grease pencil layer names are unique when set through rna.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 810db9f3634..371c387e871 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -40,6 +40,8 @@
#ifdef RNA_RUNTIME
+#include "BLI_path_util.h"
+
static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
{
bGPDlayer *gpl= (bGPDlayer *)ptr->data;
@@ -90,6 +92,17 @@ static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
}
}
+void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
+{
+ bGPdata *gpd= ptr->id.data;
+ bGPDlayer *gpl= ptr->data;
+
+ /* copy the new name into the name slot */
+ BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
+
+ BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
+}
+
#else
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
@@ -176,6 +189,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
/* Name */
prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Info", "Layer name");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_info_set");
RNA_def_struct_name_property(srna, prop);
/* Frames */