From 784d09a87c34526a1fa3ae1bca33cec278e00665 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 8 Jul 2023 15:55:13 +0200 Subject: [PATCH] LibOverride: Fix diffing code not always cleaning unused operations. In RNA collections cases, the cleaning code was buggy and could end up never cleaning actually unused liboverride operations, resulting in sometimes tens of garbage operations on e.g. Collection's objects list. This was a fairly severe bug, since it could lead to very broken overrides of collections in some cases when things start to get broken in the production file, amplifying greatly initially small issues. --- source/blender/makesrna/intern/rna_access_compare_override.cc | 4 +++- source/blender/makesrna/intern/rna_rna.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_access_compare_override.cc b/source/blender/makesrna/intern/rna_access_compare_override.cc index d2953ef7673..4ced1c15877 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.cc +++ b/source/blender/makesrna/intern/rna_access_compare_override.cc @@ -823,7 +823,9 @@ bool RNA_struct_override_matches(Main *bmain, op ? op->operations.first : nullptr); if (op != nullptr) { - BKE_lib_override_library_operations_tag(op, LIBOVERRIDE_PROP_OP_TAG_UNUSED, false); + /* Do not use #BKE_lib_override_library_operations_tag here, in collection case some of the + * operations may still be unused. */ + op->tag &= ~LIBOVERRIDE_PROP_OP_TAG_UNUSED; } if ((do_restore || do_tag_for_restore) && diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 983b2b2a6f2..e41c26e2fb0 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1455,6 +1455,7 @@ static int rna_property_override_diff_propptr(Main *bmain, rna_itemindex_a, true, NULL); + opop->tag &= ~LIBOVERRIDE_PROP_OP_TAG_UNUSED; BLI_assert(opop != NULL); }