diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-03-28 10:39:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-03-28 10:48:57 +0300 |
commit | 3944560b4a3a8c08a51c955977e3be3ae07a1afa (patch) | |
tree | 0331dc9a1bf16f1c3ff34428943f6caf4934c916 /source | |
parent | 0a6bca1f75398aa9acbeae8bd596550cd2ee23e6 (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')
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 8 |
4 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 13ba1957a32..ef567044282 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -574,8 +574,8 @@ bool BKE_brush_delete(Main *bmain, Brush *brush) if (brush->id.tag & LIB_TAG_INDIRECT) { return false; } - if (BKE_library_ID_is_indirectly_used(bmain, brush) && ID_REAL_USERS(brush) <= 1 && - ID_EXTRA_USERS(brush) == 0) { + if (ID_REAL_USERS(brush) <= 1 && ID_EXTRA_USERS(brush) == 0 && + BKE_library_ID_is_indirectly_used(bmain, brush)) { return false; } 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 " diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 681f7fab18a..7fe66b017a4 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -466,7 +466,7 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto BKE_reportf(reports, RPT_WARNING, "Cannot delete indirectly linked id '%s'", id->name); return; } - if (BKE_library_ID_is_indirectly_used(bmain, id) && ID_REAL_USERS(id) <= 1) { + if (ID_REAL_USERS(id) <= 1 && BKE_library_ID_is_indirectly_used(bmain, id)) { BKE_reportf(reports, RPT_WARNING, "Cannot delete id '%s', indirectly used data-blocks need at least one user", diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 95ff42a9946..66eb6ab15dc 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -699,8 +699,8 @@ static void outliner_object_delete_fn(bContext *C, ReportList *reports, Scene *s reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", ob->id.name + 2); return; } - 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)) { BKE_reportf(reports, RPT_WARNING, "Cannot delete object '%s' from scene '%s', indirectly used objects need at " @@ -1422,8 +1422,8 @@ static Base *outline_batch_delete_hierarchy( base->object->id.name + 2); return base_next; } - if (BKE_library_ID_is_indirectly_used(bmain, object) && ID_REAL_USERS(object) <= 1 && - ID_EXTRA_USERS(object) == 0) { + if (ID_REAL_USERS(object) <= 1 && ID_EXTRA_USERS(object) == 0 && + BKE_library_ID_is_indirectly_used(bmain, object)) { BKE_reportf(reports, RPT_WARNING, "Cannot delete object '%s' from scene '%s', indirectly used objects need at least " |