diff options
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9cbe6056dc4..b661a1e7696 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2721,7 +2721,7 @@ static void lib_link_id(FileData *fd, Main *bmain, ID *id); static void lib_link_nodetree(FileData *fd, Main *bmain, bNodeTree *ntree); static void lib_link_collection(FileData *fd, Main *bmain, Collection *collection); -static void lib_link_id_private_id(FileData *fd, Main *bmain, ID *id) +static void lib_link_id_embedded_id(FileData *fd, Main *bmain, ID *id) { /* Handle 'private IDs'. */ bNodeTree *nodetree = ntreeFromID(id); @@ -2755,7 +2755,7 @@ static void lib_link_id(FileData *fd, Main *bmain, ID *id) id->override_library->storage = newlibadr(fd, id->lib, id->override_library->storage); } - lib_link_id_private_id(fd, bmain, id); + lib_link_id_embedded_id(fd, bmain, id); } static void direct_link_id_override_property_operation_cb(FileData *fd, void *data) @@ -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_private_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_private_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_private_id(fd, id, id_old); + direct_link_id_embedded_id(fd, current_library, id, id_old); } /** \} */ @@ -8177,23 +8204,9 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - ARegion *region; v3d->camera = restore_pointer_by_name(id_map, (ID *)v3d->camera, USER_REAL); v3d->ob_center = restore_pointer_by_name(id_map, (ID *)v3d->ob_center, USER_REAL); - - /* Free render engines for now. */ - ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : - &sl->regionbase; - for (region = regionbase->first; region; region = region->next) { - if (region->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = region->regiondata; - if (rv3d && rv3d->render_engine) { - RE_engine_free(rv3d->render_engine); - rv3d->render_engine = NULL; - } - } - } } else if (sl->spacetype == SPACE_GRAPH) { SpaceGraph *sipo = (SpaceGraph *)sl; @@ -9361,19 +9374,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 +9383,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; @@ -9634,7 +9633,8 @@ static void read_libblock_undo_restore_identical( BLI_assert((fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0); BLI_assert(id_old != NULL); - id_old->tag = tag; + /* Some tags need to be preserved here. */ + id_old->tag = tag | (id_old->tag & LIB_TAG_EXTRAUSER); id_old->lib = main->curlib; id_old->us = ID_FAKE_USERS(id_old); /* Do not reset id->icon_id here, memory allocated for it remains valid. */ @@ -10920,7 +10920,7 @@ static void expand_id(FileData *fd, Main *mainvar, ID *id); static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree); static void expand_collection(FileData *fd, Main *mainvar, Collection *collection); -static void expand_id_private_id(FileData *fd, Main *mainvar, ID *id) +static void expand_id_embedded_id(FileData *fd, Main *mainvar, ID *id) { /* Handle 'private IDs'. */ bNodeTree *nodetree = ntreeFromID(id); @@ -10952,7 +10952,7 @@ static void expand_id(FileData *fd, Main *mainvar, ID *id) expand_animdata(fd, mainvar, adt); } - expand_id_private_id(fd, mainvar, id); + expand_id_embedded_id(fd, mainvar, id); } static void expand_action(FileData *fd, Main *mainvar, bAction *act) |