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.
This commit is contained in:
Campbell Barton 2023-01-18 15:43:20 +11:00
parent b380d25053
commit 1c470dbd72
2 changed files with 3 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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",