From ce317c9faa00c16437f001ac13934277de566a23 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 15 Jan 2021 19:18:26 +0100 Subject: LibOverride: fix/update/re-enable ID-related debug checks in diffing code. We should now have the tools to ensure consistency of ID pointers diffing in `rna_property_override_diff_propptr`. As a reminder, for most ID pointers we just check the actual pointer value, but this is not possible for embedded IDs like root node trees or master collections, and for fake embedded ones like shapekeys, so those should be handled as mere sub-data of their owner IDs in override context. --- source/blender/makesrna/intern/rna_rna.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index c929e3ab1aa..826e1202efc 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1279,12 +1279,22 @@ static int rna_property_override_diff_propptr(Main *bmain, 0); if (is_id) { - /* For now, once we deal with nodetrees we'll want to get rid of that one. */ - // BLI_assert(no_ownership); + /* Owned IDs (the ones we want to actually compare in depth, instead of just comparing pointer + * values) should be always properly tagged as 'virtual' overrides. */ + ID *id = propptr_a->owner_id; + if (id != NULL && !ID_IS_OVERRIDE_LIBRARY(id)) { + id = propptr_b->owner_id; + if (id != NULL && !ID_IS_OVERRIDE_LIBRARY(id)) { + id = NULL; + } + } + + BLI_assert(no_ownership || id == NULL || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id)); + UNUSED_VARS_NDEBUG(id); } if (override) { - if (no_ownership /* || is_id */ || is_null || is_type_diff || !is_valid_for_diffing) { + if (no_ownership || is_null || is_type_diff || !is_valid_for_diffing) { /* In case this pointer prop does not own its data (or one is NULL), do not compare structs! * This is a quite safe path to infinite loop, among other nasty issues. * Instead, just compare pointers themselves. */ -- cgit v1.2.3