[Bf-blender-cvs] [035b403] master: Fix T48965: Cannot Append Palette As Local Datablock.

Bastien Montagne noreply at git.blender.org
Thu Jul 28 19:32:47 CEST 2016


Commit: 035b40337a0351910486c2f9a5a00b28cde6e939
Author: Bastien Montagne
Date:   Thu Jul 28 14:40:26 2016 +0200
Branches: master
https://developer.blender.org/rB035b40337a0351910486c2f9a5a00b28cde6e939

Fix T48965: Cannot Append Palette As Local Datablock.

Palette and PaintCurve were totally missing from id_copy/id_make_local switch... :/

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

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/paint.c

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

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index bf1cfb2..0a3cc95 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -99,6 +99,8 @@ void BKE_paint_set_overlay_override(enum OverlayFlags flag);
 /* palettes */
 void                 BKE_palette_free(struct Palette *palette);
 struct Palette      *BKE_palette_add(struct Main *bmain, const char *name);
+struct Palette      *BKE_palette_copy(struct Main *bmain, struct Palette *palette);
+void                 BKE_palette_make_local(struct Main *bmain, struct Palette *palette, const bool lib_local);
 struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
 bool                 BKE_palette_is_empty(const struct Palette *palette);
 void                 BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
@@ -107,6 +109,8 @@ void                 BKE_palette_clear(struct Palette *palette);
 /* paint curves */
 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
 void BKE_paint_curve_free(struct PaintCurve *pc);
+struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, struct PaintCurve *pc);
+void               BKE_paint_curve_make_local(struct Main *bmain, struct PaintCurve *pc, const bool lib_local);
 
 void BKE_paint_init(struct Scene *sce, PaintMode mode, const char col[3]);
 void BKE_paint_free(struct Paint *p);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index ce70e5d..c4df2ed 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -105,6 +105,7 @@
 #include "BKE_mask.h"
 #include "BKE_node.h"
 #include "BKE_object.h"
+#include "BKE_paint.h"
 #include "BKE_particle.h"
 #include "BKE_packedFile.h"
 #include "BKE_sound.h"
@@ -423,6 +424,12 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
 		case ID_LS:
 			if (!test) BKE_linestyle_make_local(bmain, (FreestyleLineStyle *)id, lib_local);
 			return true;
+		case ID_PAL:
+			if (!test) BKE_palette_make_local(bmain, (Palette *)id, lib_local);
+			return true;
+		case ID_PC:
+			if (!test) BKE_paint_curve_make_local(bmain, (PaintCurve *)id, lib_local);
+			return true;
 	}
 
 	return false;
@@ -525,6 +532,12 @@ bool id_copy(Main *bmain, ID *id, ID **newid, bool test)
 		case ID_LS:
 			if (!test) *newid = (ID *)BKE_linestyle_copy(bmain, (FreestyleLineStyle *)id);
 			return true;
+		case ID_PAL:
+			if (!test) *newid = (ID *)BKE_palette_copy(bmain, (Palette *)id);
+			return true;
+		case ID_PC:
+			if (!test) *newid = (ID *)BKE_paint_curve_copy(bmain, (PaintCurve *)id);
+			return true;
 	}
 	
 	return false;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 8c15026..53675f3 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)
 {




More information about the Bf-blender-cvs mailing list