[Bf-blender-cvs] [196520fe7d] master: GPencil: Fix unreported error in animation after rename items

Antonio Vazquez noreply at git.blender.org
Wed Jan 18 12:29:25 CET 2017


Commit: 196520fe7d813996193423f896c5aa38c084cac2
Author: Antonio Vazquez
Date:   Wed Jan 18 12:25:49 2017 +0100
Branches: master
https://developer.blender.org/rB196520fe7d813996193423f896c5aa38c084cac2

GPencil: Fix unreported error in animation after rename items

If the layers or the colors were renamed, the animation data was wrong
because the data path was not updated.

I also have fixed a possible stroke color name update if the name was duplicated moving
the rename function call after checking unique name.

===================================================================

M	source/blender/makesrna/intern/rna_gpencil.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 9c66a86dce..95d567698d 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -31,6 +31,8 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "BKE_animsys.h"
+
 #include "BLI_string_utils.h"
 #include "BLI_utildefines.h"
 
@@ -353,10 +355,16 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
 	bGPdata *gpd = ptr->id.data;
 	bGPDlayer *gpl = ptr->data;
 
+	char oldname[128] = "";
+	BLI_strncpy(oldname, gpl->info, sizeof(oldname));
+
 	/* copy the new name into the name slot */
 	BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
 
 	BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
+
+	/* now fix animation paths */
+	BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info);
 }
 
 static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value)
@@ -814,14 +822,20 @@ static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value)
 	bGPdata *gpd = ptr->id.data;
 	bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
 	bGPDpalettecolor *palcolor = ptr->data;
-
-	/* rename all strokes */
-	BKE_gpencil_palettecolor_changename(gpd, palcolor->info, value);
+	
+	char oldname[64] = "";
+	BLI_strncpy(oldname, palcolor->info, sizeof(oldname));
 
 	/* copy the new name into the name slot */
 	BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info));
 	BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
 	               sizeof(palcolor->info));
+	
+	/* rename all strokes */
+	BKE_gpencil_palettecolor_changename(gpd, oldname, palcolor->info);
+
+	/* now fix animation paths */
+	BKE_animdata_fix_paths_rename_all(&gpd->id, "colors", oldname, palcolor->info);
 }
 
 static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value)




More information about the Bf-blender-cvs mailing list