diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-13 08:06:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-13 08:06:32 +0400 |
commit | 03c72a5ba0fd29542eced2276f63241d3b8cd572 (patch) | |
tree | bee3f945ba15fb2e156915f0cf0dceb49d89c0bd /source/blender | |
parent | 49b1a319c44f0ac3db45652f4cb022d2e1a93d40 (diff) |
ensure grease pencil layer names are unique when set through rna.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_gpencil_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil.c | 14 |
3 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 06ca7b7b509..fa493315d4b 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -185,7 +185,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) /* auto-name */ strcpy(gpl->info, "GP_Layer"); - BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info)); + BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); /* make this one the active one */ gpencil_layer_setactive(gpd, gpl); diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index b259d592864..a4d0b3685e3 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -99,7 +99,8 @@ typedef struct bGPDlayer { float color[4]; /* color that should be used to draw all the strokes in this layer */ - char info[128]; /* optional reference info about this layer (i.e. "director's comments, 12/3") */ + char info[128]; /* optional reference info about this layer (i.e. "director's comments, 12/3") + * this is used for the name of the layer too and kept unique. */ } bGPDlayer; /* bGPDlayer->flag */ 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 */ |