[Bf-blender-cvs] [1fd5c90e63b] master: DatablockManagement: Cleanup: get rid of `BKE_collection_copy_master()`.

Bastien Montagne noreply at git.blender.org
Mon Sep 2 18:49:21 CEST 2019


Commit: 1fd5c90e63b6306e070db090bd272eb4ec942f60
Author: Bastien Montagne
Date:   Mon Sep 2 17:42:03 2019 +0200
Branches: master
https://developer.blender.org/rB1fd5c90e63b6306e070db090bd272eb4ec942f60

DatablockManagement: Cleanup: get rid of `BKE_collection_copy_master()`.

Now that we 'properly' support private ID data in lib management, there
is no reason anymore to have that custom func, badly named and
by-passing the whole generic ID management code.

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

M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/scene.c

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

diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 6847efc8eb3..0d33d86ec16 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -70,9 +70,6 @@ struct Collection *BKE_collection_duplicate(struct Main *bmain,
                                             const bool do_hierarchy,
                                             const bool do_objects,
                                             const bool do_obdata);
-struct Collection *BKE_collection_copy_master(struct Main *bmain,
-                                              struct Collection *collection,
-                                              const int flag);
 
 /* Master Collection for Scene */
 
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 0c84dded53d..f2098cc2430 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -203,6 +203,9 @@ void BKE_collection_copy_data(Main *bmain,
                               const Collection *collection_src,
                               const int flag)
 {
+  BLI_assert(((collection_src->flag & COLLECTION_IS_MASTER) != 0) ==
+             ((collection_src->id.flag & LIB_PRIVATE_DATA) != 0));
+
   /* Do not copy collection's preview (same behavior as for objects). */
   if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
     BKE_previewimg_id_copy(&collection_dst->id, &collection_src->id);
@@ -366,16 +369,6 @@ Collection *BKE_collection_duplicate(Main *bmain,
   return collection_new;
 }
 
-Collection *BKE_collection_copy_master(Main *bmain, Collection *collection, const int flag)
-{
-  BLI_assert(collection->flag & COLLECTION_IS_MASTER);
-  BLI_assert(collection->id.flag & LIB_PRIVATE_DATA);
-
-  Collection *collection_dst = MEM_dupallocN(collection);
-  BKE_collection_copy_data(bmain, collection_dst, collection, flag);
-  return collection_dst;
-}
-
 void BKE_collection_make_local(Main *bmain, Collection *collection, const bool lib_local)
 {
   BKE_id_make_local_generic(bmain, &collection->id, true, lib_local);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index bfffe21ef56..885ce415ade 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -248,8 +248,10 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons
 
   /* Master Collection */
   if (sce_src->master_collection) {
-    sce_dst->master_collection = BKE_collection_copy_master(
-        bmain, sce_src->master_collection, flag);
+    BKE_id_copy_ex(bmain,
+                   (ID *)sce_src->master_collection,
+                   (ID **)&sce_dst->master_collection,
+                   flag_private_id_data);
   }
 
   /* View Layers */



More information about the Bf-blender-cvs mailing list