diff options
author | Bastien Montagne <bastien@blender.org> | 2020-09-24 22:05:14 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-09-24 22:08:27 +0300 |
commit | 9910b5024ead36109d85c6d0424a804d42e115e7 (patch) | |
tree | 3d70d2874096a669ec40cd182e9f94efff5af162 /source/blender/blenkernel/intern | |
parent | 934b515bc18831366dbc53a26558625db5c43716 (diff) |
Fix part of asserts in LibOverride when resynching.
We can only re-apply overrides fron the old local overrides to the newly
generated ones after all IDs have been properly remapped and renamed.
Otherwise override operations based on ID names may fail.
Related to T81059, found while investigating it.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/lib_override.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 4e25f52cf23..4a577bbd428 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -783,16 +783,6 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_ op_new = op_new->next, op_old = op_old->next) { lib_override_library_property_copy(op_new, op_old); } - - /* Apply rules on new override ID using old one as 'source' data. */ - /* Note that since we already remapped ID pointers in old override IDs to new ones, we - * can also apply ID pointer override rules safely here. */ - PointerRNA rnaptr_src, rnaptr_dst; - RNA_id_pointer_create(id_override_old, &rnaptr_src); - RNA_id_pointer_create(id_override_new, &rnaptr_dst); - - RNA_struct_override_apply( - bmain, &rnaptr_dst, &rnaptr_src, NULL, id_override_new->override_library); } } } @@ -800,6 +790,29 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene *scene, ViewLayer *view_ } FOREACH_MAIN_LISTBASE_END; + /* We need to apply override rules in a separate loop, after all ID pointers have been properly + * remapped, and all new local override IDs have gotten their proper original names, otherwise + * override operations based on those ID names would fail. */ + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (id->tag & LIB_TAG_DOIT && id->newid != NULL && ID_IS_LINKED(id)) { + ID *id_override_new = id->newid; + ID *id_override_old = BLI_ghash_lookup(linkedref_to_old_override, id); + + if (id_override_old != NULL) { + /* Apply rules on new override ID using old one as 'source' data. */ + /* Note that since we already remapped ID pointers in old override IDs to new ones, we + * can also apply ID pointer override rules safely here. */ + PointerRNA rnaptr_src, rnaptr_dst; + RNA_id_pointer_create(id_override_old, &rnaptr_src); + RNA_id_pointer_create(id_override_new, &rnaptr_dst); + + RNA_struct_override_apply( + bmain, &rnaptr_dst, &rnaptr_src, NULL, id_override_new->override_library); + } + } + } + FOREACH_MAIN_ID_END; + /* Delete old override IDs. * Note that we have to use tagged group deletion here, since ID deletion also uses LIB_TAG_DOIT. * This improves performances anyway, so everything is fine. */ |