[Bf-blender-cvs] [b9aa2acecdc] master: Refactor: Move collection foreach_id to new IDTypeInfo structure.

Bastien Montagne noreply at git.blender.org
Wed May 20 18:43:54 CEST 2020


Commit: b9aa2acecdc9b9829d190252a4ca7ad8cf5ce0cc
Author: Bastien Montagne
Date:   Wed May 20 18:43:25 2020 +0200
Branches: master
https://developer.blender.org/rBb9aa2acecdc9b9829d190252a4ca7ad8cf5ce0cc

Refactor: Move collection foreach_id to new IDTypeInfo structure.

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

M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/lib_query.c

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

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 583bb39a851..c1d77fd5f9e 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -34,6 +34,7 @@
 #include "BKE_idtype.h"
 #include "BKE_layer.h"
 #include "BKE_lib_id.h"
+#include "BKE_lib_query.h"
 #include "BKE_lib_remap.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
@@ -128,6 +129,28 @@ static void collection_free_data(ID *id)
   BKE_collection_object_cache_free(collection);
 }
 
+static void collection_foreach_id(ID *id, LibraryForeachIDData *data)
+{
+  Collection *collection = (Collection *)id;
+
+  LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
+    BKE_LIB_FOREACHID_PROCESS(data, cob->ob, IDWALK_CB_USER);
+  }
+  LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
+    BKE_LIB_FOREACHID_PROCESS(data, child->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_USER);
+  }
+  LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
+    /* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
+     * anyway... */
+    const int cb_flag = ((parent->collection != NULL &&
+                          (parent->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ?
+                             IDWALK_CB_EMBEDDED :
+                             IDWALK_CB_NOP);
+    BKE_LIB_FOREACHID_PROCESS(
+        data, parent->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_LOOPBACK | cb_flag);
+  }
+}
+
 IDTypeInfo IDType_ID_GR = {
     .id_code = ID_GR,
     .id_filter = FILTER_ID_GR,
@@ -142,6 +165,7 @@ IDTypeInfo IDType_ID_GR = {
     .copy_data = collection_copy_data,
     .free_data = collection_free_data,
     .make_local = NULL,
+    .foreach_id = collection_foreach_id,
 };
 
 /***************************** Add Collection *******************************/
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 66c04a75db6..753612eb0ab 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -786,24 +786,7 @@ static void library_foreach_ID_link(Main *bmain,
       }
 
       case ID_GR: {
-        Collection *collection = (Collection *)id;
-
-        LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
-          FOREACH_CALLBACK_INVOKE(&data, cob->ob, IDWALK_CB_USER);
-        }
-        LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
-          FOREACH_CALLBACK_INVOKE(&data, child->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_USER);
-        }
-        LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
-          /* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
-           * anyway... */
-          const int cb_flag = ((parent->collection != NULL &&
-                                (parent->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ?
-                                   IDWALK_CB_EMBEDDED :
-                                   IDWALK_CB_NOP);
-          FOREACH_CALLBACK_INVOKE(
-              &data, parent->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_LOOPBACK | cb_flag);
-        }
+        BLI_assert(0);
         break;
       }



More information about the Bf-blender-cvs mailing list