[Bf-blender-cvs] [1c470dbd721] master: Cleanup: replace BLI_findptr with BKE_collection_has_object

Campbell Barton noreply at git.blender.org
Wed Jan 18 05:46:25 CET 2023


Commit: 1c470dbd7219a0edc2c06323b8144f9a22c50b72
Author: Campbell Barton
Date:   Wed Jan 18 15:43:20 2023 +1100
Branches: master
https://developer.blender.org/rB1c470dbd7219a0edc2c06323b8144f9a22c50b72

Cleanup: replace BLI_findptr with BKE_collection_has_object

Also swap the order of checks in collection_object_add to perform
the comparison before calling collection_find_child_recursive.

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

M	source/blender/blenkernel/intern/collection.c
M	source/blender/editors/object/object_edit.c

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

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index de785ddd38d..8b430546644 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1064,8 +1064,8 @@ static bool collection_object_add(
 {
   if (ob->instance_collection) {
     /* Cyclic dependency check. */
-    if (collection_find_child_recursive(ob->instance_collection, collection) ||
-        ob->instance_collection == collection) {
+    if ((ob->instance_collection == collection) ||
+        collection_find_child_recursive(ob->instance_collection, collection)) {
       return false;
     }
   }
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index e9b176daf4a..b1cebc32513 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1876,8 +1876,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
   Object *single_object = BLI_listbase_is_single(&objects) ? ((LinkData *)objects.first)->data :
                                                              NULL;
 
-  if ((single_object != NULL) && is_link &&
-      BLI_findptr(&collection->gobject, single_object, offsetof(CollectionObject, ob))) {
+  if ((single_object != NULL) && is_link && BKE_collection_has_object(collection, single_object)) {
     BKE_reportf(op->reports,
                 RPT_ERROR,
                 "%s already in %s",



More information about the Bf-blender-cvs mailing list