[Bf-blender-cvs] [2cb0e188e25] greasepencil-object: Fix: Make Single User wasn't supported for GP Objects

Joshua Leung noreply at git.blender.org
Tue Sep 26 04:25:16 CEST 2017


Commit: 2cb0e188e257c9e45e93dc27459c0dba002bd42e
Author: Joshua Leung
Date:   Tue Sep 26 15:13:22 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB2cb0e188e257c9e45e93dc27459c0dba002bd42e

Fix: Make Single User wasn't supported for GP Objects

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

M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/object/object_relations.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index a1f5f941229..e806626b864 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -86,7 +86,9 @@ void BKE_gpencil_create_monkey(struct bContext *C, struct bGPdata *gpd);
 struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
 struct bGPDframe *BKE_gpencil_frame_color_duplicate(const struct bGPDframe *gpf_src);
 struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
+
 void BKE_gpencil_copy_data(struct Main *bmain, struct bGPdata *gpd_dst, const struct bGPdata *gpd_src, const int flag);
+struct bGPdata   *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd);
 struct bGPdata   *BKE_gpencil_data_duplicate(struct Main *bmain, const struct bGPdata *gpd, bool internal_copy);
 
 void BKE_gpencil_make_local(struct Main *bmain, struct bGPdata *gpd, const bool lib_local);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 0fbfb0861c4..ff6f2924394 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -975,7 +975,16 @@ void BKE_gpencil_copy_data(Main *UNUSED(bmain), bGPdata *gpd_dst, const bGPdata
 	}
 }
 
+/* Standard API to make a copy of GP datablock, separate from copying its data */
+bGPdata *BKE_gpencil_copy(Main *bmain, const bGPdata *gpd)
+{
+	bGPdata *gpd_copy;
+	BKE_id_copy_ex(bmain, &gpd->id, (ID **)&gpd_copy, 0, false);
+	return gpd_copy;
+}
+
 /* make a copy of a given gpencil datablock */
+// XXX: Should this be deprecated?
 bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool internal_copy)
 {
 	const bGPDlayer *gpl_src;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index f87e34833b1..cf7641671a3 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -70,6 +70,7 @@
 #include "BKE_DerivedMesh.h"
 #include "BKE_displist.h"
 #include "BKE_global.h"
+#include "BKE_gpencil.h"
 #include "BKE_group.h"
 #include "BKE_fcurve.h"
 #include "BKE_idprop.h"
@@ -1842,6 +1843,9 @@ static void single_obdata_users(Main *bmain, Scene *scene, SceneLayer *sl, const
 					case OB_SPEAKER:
 						ob->data = ID_NEW_SET(ob->data, BKE_speaker_copy(bmain, ob->data));
 						break;
+					case OB_GPENCIL:
+						ob->data = ID_NEW_SET(ob->data, BKE_gpencil_copy(bmain, ob->data));
+						break;
 					default:
 						if (G.debug & G_DEBUG)
 							printf("ERROR %s: can't copy %s\n", __func__, id->name);



More information about the Bf-blender-cvs mailing list