Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-03-28 10:39:18 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-28 10:48:57 +0300
commit3944560b4a3a8c08a51c955977e3be3ae07a1afa (patch)
tree0331dc9a1bf16f1c3ff34428943f6caf4934c916 /source/blender/editors/object
parent0a6bca1f75398aa9acbeae8bd596550cd2ee23e6 (diff)
Cleanup: re-order expensive checks for indirect ID use
Check for indirect ID use after other simple user count checks are made. Also assert ED_object_base_free_and_unlink_no_indirect_check object argument isn't indirectly used.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 7c192190c06..7f189abe870 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1899,8 +1899,8 @@ void OBJECT_OT_pointcloud_add(wmOperatorType *ot)
/* note: now unlinks constraints as well */
void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
{
- if (BKE_library_ID_is_indirectly_used(bmain, ob) && ID_REAL_USERS(ob) <= 1 &&
- ID_EXTRA_USERS(ob) == 0) {
+ if (ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0 &&
+ BKE_library_ID_is_indirectly_used(bmain, ob)) {
/* We cannot delete indirectly used object... */
printf(
"WARNING, undeletable object '%s', should have been caught before reaching this "
@@ -1920,6 +1920,7 @@ void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob)
*/
void ED_object_base_free_and_unlink_no_indirect_check(Main *bmain, Scene *scene, Object *ob)
{
+ BLI_assert(!BKE_library_ID_is_indirectly_used(bmain, ob));
DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_BASE_FLAGS);
BKE_scene_collections_object_remove(bmain, scene, ob, true);
}
@@ -1940,7 +1941,6 @@ static int object_delete_exec(bContext *C, wmOperator *op)
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
- const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, ob);
if (ob->id.tag & LIB_TAG_INDIRECT) {
/* Can this case ever happen? */
BKE_reportf(op->reports,
@@ -1949,7 +1949,9 @@ static int object_delete_exec(bContext *C, wmOperator *op)
ob->id.name + 2);
continue;
}
- if (is_indirectly_used && ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0) {
+
+ if (ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0 &&
+ BKE_library_ID_is_indirectly_used(bmain, ob)) {
BKE_reportf(op->reports,
RPT_WARNING,
"Cannot delete object '%s' from scene '%s', indirectly used objects need at "