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.
This commit is contained in:
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
#include "BKE_animsys.h"
|
||||||
|
|
||||||
#include "BLI_string_utils.h"
|
#include "BLI_string_utils.h"
|
||||||
#include "BLI_utildefines.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;
|
bGPdata *gpd = ptr->id.data;
|
||||||
bGPDlayer *gpl = ptr->data;
|
bGPDlayer *gpl = ptr->data;
|
||||||
|
|
||||||
|
char oldname[128] = "";
|
||||||
|
BLI_strncpy(oldname, gpl->info, sizeof(oldname));
|
||||||
|
|
||||||
/* copy the new name into the name slot */
|
/* copy the new name into the name slot */
|
||||||
BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
|
BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info));
|
||||||
|
|
||||||
BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), 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)
|
static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value)
|
||||||
@@ -815,13 +823,19 @@ static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value)
|
|||||||
bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
|
bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
|
||||||
bGPDpalettecolor *palcolor = ptr->data;
|
bGPDpalettecolor *palcolor = ptr->data;
|
||||||
|
|
||||||
/* rename all strokes */
|
char oldname[64] = "";
|
||||||
BKE_gpencil_palettecolor_changename(gpd, palcolor->info, value);
|
BLI_strncpy(oldname, palcolor->info, sizeof(oldname));
|
||||||
|
|
||||||
/* copy the new name into the name slot */
|
/* copy the new name into the name slot */
|
||||||
BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info));
|
BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info));
|
||||||
BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
|
BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info),
|
||||||
sizeof(palcolor->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)
|
static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value)
|
||||||
|
|||||||
Reference in New Issue
Block a user