[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40979] trunk/blender/source/blender: ensure grease pencil layer names are unique when set through rna.
Campbell Barton
ideasman42 at gmail.com
Thu Oct 13 06:06:38 CEST 2011
Revision: 40979
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40979
Author: campbellbarton
Date: 2011-10-13 04:06:32 +0000 (Thu, 13 Oct 2011)
Log Message:
-----------
ensure grease pencil layer names are unique when set through rna.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/gpencil.c
trunk/blender/source/blender/makesdna/DNA_gpencil_types.h
trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
Modified: trunk/blender/source/blender/blenkernel/intern/gpencil.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/gpencil.c 2011-10-13 03:35:08 UTC (rev 40978)
+++ trunk/blender/source/blender/blenkernel/intern/gpencil.c 2011-10-13 04:06:32 UTC (rev 40979)
@@ -185,7 +185,7 @@
/* 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);
Modified: trunk/blender/source/blender/makesdna/DNA_gpencil_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_gpencil_types.h 2011-10-13 03:35:08 UTC (rev 40978)
+++ trunk/blender/source/blender/makesdna/DNA_gpencil_types.h 2011-10-13 04:06:32 UTC (rev 40979)
@@ -99,7 +99,8 @@
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 */
Modified: trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_gpencil.c 2011-10-13 03:35:08 UTC (rev 40978)
+++ trunk/blender/source/blender/makesrna/intern/rna_gpencil.c 2011-10-13 04:06:32 UTC (rev 40979)
@@ -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 @@
}
}
+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 @@
/* 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 */
More information about the Bf-blender-cvs
mailing list