From e5782df4aba90ca70fca9a949e5b546abdb12ec3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 19 Oct 2022 10:27:56 +0200 Subject: Fix (unreported) error messages about invalid ID usercount when batch-deleting IDs. Batch-delete by-passes a lot of ID usages handling in to-be-deleted IDs, so usercount of deleted IDs needs to be manually reset to avoid the annoying error messages in the console. --- source/blender/blenkernel/intern/lib_id_delete.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index a2236089093..ae5dc75c36a 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -294,6 +294,10 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion) * is never affected). */ for (ID *id = tagged_deleted_ids.first; id; id = id->next) { id->tag |= LIB_TAG_NO_MAIN; + /* Usercount needs to be reset artificially, since some usages may not be cleared in batch + * deletion (typically, if one deleted ID uses another deleted ID, this may not be cleared by + * remapping code, depending on order in which these are handled). */ + id->us = ID_FAKE_USERS(id); } } else { -- cgit v1.2.3