[Bf-blender-cvs] [b83d72242b8] greasepencil-object: Added missing support for duplicating Palette Slots when copying GP data

Joshua Leung noreply at git.blender.org
Wed Oct 4 14:17:29 CEST 2017


Commit: b83d72242b8d8fa82bbcd8891109934ed02dc3a0
Author: Joshua Leung
Date:   Thu Oct 5 00:39:38 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rBb83d72242b8d8fa82bbcd8891109934ed02dc3a0

Added missing support for duplicating Palette Slots when copying GP data

For now, it will only increment the usercount of the referenced palettes.

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

M	source/blender/blenkernel/intern/gpencil.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index ad48392fdb7..b80c392d03e 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -983,6 +983,23 @@ void BKE_gpencil_copy_data(Main *UNUSED(bmain), bGPdata *gpd_dst, const bGPdata
 		bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);  /* TODO here too could add unused flags... */
 		BLI_addtail(&gpd_dst->layers, gpl_dst);
 	}
+	
+	/* copy palette slots */
+	BLI_listbase_clear(&gpd_dst->palette_slots);
+	for (const bGPDpaletteref *palslot_src = gpd_src->palette_slots.first; palslot_src; palslot_src = palslot_src->next) {
+		bGPDpaletteref *palslot_dst = MEM_dupallocN(palslot_src);
+		
+		/* TODO: Separate out into separate function, and make use of LIB_ID_COPY flags? */
+		if (palslot_dst->palette) {
+			/* XXX: Better safe than sorry... at worst, usercount won't go down,
+			 * and the user has to reload?
+			 */
+			id_us_plus(&palslot_dst->palette->id);
+		}
+		palslot_dst->next = palslot_dst->prev = NULL;
+		
+		BLI_addtail(&gpd_dst->palette_slots, palslot_dst);
+	}
 
 	/* copy palettes */
 	BLI_listbase_clear(&gpd_dst->palettes);



More information about the Bf-blender-cvs mailing list