From 035b40337a0351910486c2f9a5a00b28cde6e939 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 28 Jul 2016 14:40:26 +0200 Subject: Fix T48965: Cannot Append Palette As Local Datablock. Palette and PaintCurve were totally missing from id_copy/id_make_local switch... :/ --- source/blender/blenkernel/intern/paint.c | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source/blender/blenkernel/intern/paint.c') diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 8c1502643c5..53675f33a69 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -314,6 +314,26 @@ PaintCurve *BKE_paint_curve_add(Main *bmain, const char *name) return pc; } +PaintCurve *BKE_paint_curve_copy(Main *bmain, PaintCurve *pc) +{ + PaintCurve *pc_new; + + pc_new = BKE_libblock_copy(bmain, &pc->id); + + if (pc->tot_points != 0) { + pc_new->points = MEM_dupallocN(pc->points); + } + + BKE_id_copy_ensure_local(bmain, &pc->id, &pc_new->id); + + return pc_new; +} + +void BKE_paint_curve_make_local(Main *bmain, PaintCurve *pc, const bool lib_local) +{ + BKE_id_make_local_generic(bmain, &pc->id, true, lib_local); +} + Palette *BKE_paint_palette(Paint *p) { return p ? p->palette : NULL; @@ -376,6 +396,24 @@ Palette *BKE_palette_add(Main *bmain, const char *name) return palette; } +Palette *BKE_palette_copy(Main *bmain, Palette *palette) +{ + Palette *palette_new; + + palette_new = BKE_libblock_copy(bmain, &palette->id); + + BLI_duplicatelist(&palette_new->colors, &palette->colors); + + BKE_id_copy_ensure_local(bmain, &palette->id, &palette_new->id); + + return palette_new; +} + +void BKE_palette_make_local(Main *bmain, Palette *palette, bool lib_local) +{ + BKE_id_make_local_generic(bmain, &palette->id, true, lib_local); +} + /** Free (or release) any data used by this palette (does not free the palette itself). */ void BKE_palette_free(Palette *palette) { -- cgit v1.2.3