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/layer.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/layer.c')
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index f3c0d5da6ee..4198e6ded9c 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -32,6 +32,7 @@ #include "BKE_freestyle.h" #include "BKE_idprop.h" #include "BKE_layer.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_object.h" @@ -698,6 +699,10 @@ static short layer_collection_sync(ViewLayer *view_layer, lc->flag = parent_exclude; } + /* Tag linked collection as a weak reference so we keep the layer + * collection pointer on file load and remember exclude state. */ + id_lib_indirect_weak_link(&collection->id); + /* Collection restrict is inherited. */ short child_restrict = parent_restrict; short child_layer_restrict = parent_layer_restrict; @@ -735,6 +740,10 @@ static short layer_collection_sync(ViewLayer *view_layer, continue; } + /* Tag linked object as a weak reference so we keep the object + * base pointer on file load and remember hidden state. */ + id_lib_indirect_weak_link(&cob->ob->id); + void **base_p; Base *base; if (BLI_ghash_ensure_p(view_layer->object_bases_hash, cob->ob, &base_p)) { |