diff options
author | Bastien Montagne <bastien@blender.org> | 2020-05-15 19:02:10 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-05-15 19:02:10 +0300 |
commit | ecec6547c71af03755b07b19ec19d11296aafa8b (patch) | |
tree | 3b5229d64d93f89bb7a3793ae95859e535b67ee4 /source/blender/blenloader/intern | |
parent | b14243be77b2fdc30781e4c5f5d90c27d08dbbfb (diff) | |
parent | 9632a0620135b78339b7511b173f31e70427d4eb (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 22189201ee8..2887e8b2a8b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2779,18 +2779,22 @@ static void direct_link_id_override_property_cb(FileData *fd, void *data) link_list_ex(fd, &op->operations, direct_link_id_override_property_operation_cb); } -static void direct_link_id_common(FileData *fd, ID *id, ID *id_old, const int tag); +static void direct_link_id_common( + FileData *fd, Library *current_library, ID *id, ID *id_old, const int tag); static void direct_link_nodetree(FileData *fd, bNodeTree *ntree); static void direct_link_collection(FileData *fd, Collection *collection); -static void direct_link_id_embedded_id(FileData *fd, ID *id, ID *id_old) +static void direct_link_id_embedded_id(FileData *fd, Library *current_library, ID *id, ID *id_old) { /* Handle 'private IDs'. */ bNodeTree **nodetree = BKE_ntree_ptr_from_id(id); if (nodetree != NULL && *nodetree != NULL) { *nodetree = newdataadr(fd, *nodetree); - direct_link_id_common( - fd, (ID *)*nodetree, id_old != NULL ? (ID *)ntreeFromID(id_old) : NULL, 0); + direct_link_id_common(fd, + current_library, + (ID *)*nodetree, + id_old != NULL ? (ID *)ntreeFromID(id_old) : NULL, + 0); direct_link_nodetree(fd, *nodetree); } @@ -2799,6 +2803,7 @@ static void direct_link_id_embedded_id(FileData *fd, ID *id, ID *id_old) if (scene->master_collection != NULL) { scene->master_collection = newdataadr(fd, scene->master_collection); direct_link_id_common(fd, + current_library, &scene->master_collection->id, id_old != NULL ? &((Scene *)id_old)->master_collection->id : NULL, 0); @@ -2863,18 +2868,40 @@ static int direct_link_id_restore_recalc(const FileData *fd, return recalc; } -static void direct_link_id_common(FileData *fd, ID *id, ID *id_old, const int tag) +static void direct_link_id_common( + FileData *fd, Library *current_library, ID *id, ID *id_old, const int tag) { + if (fd->memfile == NULL) { + /* When actually reading a file , we do want to reset/re-generate session uuids. + * In undo case, we want to re-use existing ones. */ + id->session_uuid = MAIN_ID_SESSION_UUID_UNSET; + } + + BKE_lib_libblock_session_uuid_ensure(id); + + id->lib = current_library; + id->us = ID_FAKE_USERS(id); + id->icon_id = 0; + id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */ + id->orig_id = NULL; + id->py_instance = NULL; + + /* Initialize with provided tag. */ + id->tag = tag; + + if (tag & LIB_TAG_ID_LINK_PLACEHOLDER) { + /* For placeholder we only need to set the tag and properly init generic ID fieds above, no + * further data to read. */ + return; + } + /*link direct data of ID properties*/ if (id->properties) { id->properties = newdataadr(fd, id->properties); /* this case means the data was written incorrectly, it should not happen */ IDP_DirectLinkGroup_OrFree(&id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); } - id->py_instance = NULL; - /* Initialize with provided tag. */ - id->tag = tag; id->flag &= ~LIB_INDIRECT_WEAK_LINK; /* NOTE: It is important to not clear the recalc flags for undo/redo. @@ -2907,7 +2934,7 @@ static void direct_link_id_common(FileData *fd, ID *id, ID *id_old, const int ta } /* Handle 'private IDs'. */ - direct_link_id_embedded_id(fd, id, id_old); + direct_link_id_embedded_id(fd, current_library, id, id_old); } /** \} */ @@ -9361,19 +9388,8 @@ static const char *dataname(short id_code) static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *id_old) { - if (fd->memfile == NULL) { - /* When actually reading a file , we do want to reset/re-generate session uuids. - * In undo case, we want to re-use existing ones. */ - id->session_uuid = MAIN_ID_SESSION_UUID_UNSET; - } - - BKE_lib_libblock_session_uuid_ensure(id); - - id->lib = main->curlib; - id->us = ID_FAKE_USERS(id); - id->icon_id = 0; - id->newid = NULL; /* Needed because .blend may have been saved with crap value here... */ - id->orig_id = NULL; + /* Read part of datablock that is common between real and embedded datablocks. */ + direct_link_id_common(fd, main->curlib, id, id_old, tag); if (tag & LIB_TAG_ID_LINK_PLACEHOLDER) { /* For placeholder we only need to set the tag, no further data to read. */ @@ -9381,9 +9397,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * return true; } - /* Read part of datablock that is common between real and embedded datablocks. */ - direct_link_id_common(fd, id, id_old, tag); - /* XXX Very weakly handled currently, see comment in read_libblock() before trying to * use it for anything new. */ bool success = true; |