diff options
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_remap.c | 1 |
3 files changed, 23 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)) { 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, diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 7554dad5fb0..45dbb4b6ec1 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -497,6 +497,7 @@ static void libblock_remap_data( if (new_id && (new_id->tag & LIB_TAG_INDIRECT) && (r_id_remap_data->status & ID_REMAP_IS_LINKED_DIRECT)) { new_id->tag &= ~LIB_TAG_INDIRECT; + new_id->flag &= ~LIB_INDIRECT_WEAK_LINK; new_id->tag |= LIB_TAG_EXTERN; } |