diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-16 15:52:06 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-19 12:32:35 +0300 |
commit | 659ccd9cd2ee79c462147b53c18ecc8b9faf74a6 (patch) | |
tree | dfcb40573e72f2dd3f805baade1ae63d5a7dab3b /source/blender/blenkernel/intern/library.c | |
parent | e7a514369fe700dcc5a1fe433c8f709ed9595ded (diff) |
Fix T66154: viewlayer hide/exclude settings getting lost for linked collections
The problem was that the object and collection pointers in Base and
LayerCollection would get lost of file read. Normally such ID pointers would
be resolved by pointing to an ID_ID placeholder which has the datablock name,
and then replacing it will the real datablock. However ID_ID is only written
for directly linked datablocks.
This adds the concept of an indirectly linked datablock with a weak reference
to it. For this we write an ID_ID_WEAK_REF code, which is a reference that
will only be resolved if the datablock was read for another reason.
Differential Revision: https://developer.blender.org/D4416
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 367c2fbbdda..468d0e97ece 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -165,12 +165,23 @@ void id_lib_extern(ID *id) BLI_assert(BKE_idcode_is_linkable(GS(id->name))); if (id->tag & LIB_TAG_INDIRECT) { id->tag &= ~LIB_TAG_INDIRECT; + id->flag &= ~LIB_INDIRECT_WEAK_LINK; id->tag |= LIB_TAG_EXTERN; id->lib->parent = NULL; } } } +void id_lib_indirect_weak_link(ID *id) +{ + if (id && ID_IS_LINKED(id)) { + BLI_assert(BKE_idcode_is_linkable(GS(id->name))); + if (id->tag & LIB_TAG_INDIRECT) { + id->flag |= LIB_INDIRECT_WEAK_LINK; + } + } +} + /** * Ensure we have a real user * @@ -1768,6 +1779,7 @@ void id_clear_lib_data_ex(Main *bmain, ID *id, const bool id_in_mainlist) id->lib = NULL; id->tag &= ~(LIB_TAG_INDIRECT | LIB_TAG_EXTERN); + id->flag &= ~LIB_INDIRECT_WEAK_LINK; if (id_in_mainlist) { if (BKE_id_new_name_validate(which_libbase(bmain, GS(id->name)), id, NULL)) { bmain->is_memfile_undo_written = false; @@ -1981,6 +1993,7 @@ void BKE_library_make_local(Main *bmain, if (id->lib == NULL) { id->tag &= ~(LIB_TAG_EXTERN | LIB_TAG_INDIRECT | LIB_TAG_NEW); + id->flag &= ~LIB_INDIRECT_WEAK_LINK; } /* The check on the fourth line (LIB_TAG_PRE_EXISTING) is done so it's possible to tag data * you don't want to be made local, used for appending data, |