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:
authorAntonio Vazquez <blendergit@gmail.com>2017-01-18 14:25:49 +0300
committerAntonio Vazquez <blendergit@gmail.com>2017-01-18 14:29:02 +0300
commit196520fe7d813996193423f896c5aa38c084cac2 (patch)
treebe774397f6fc3acd196d2c31ed2cb6cab9261bfa /source/blender/makesrna/intern/rna_gpencil.c
parentd216313732e69317a77de2a9368483f5c922c32c (diff)
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.
Diffstat (limited to 'source/blender/makesrna/intern/rna_gpencil.c')
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 9c66a86dcee..95d567698d8 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)