source/blender/blenloader/intern/readfile.c
static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main, ID *id, ID *id_old)
{
  /* During memfile undo, if an ID changed and we cannot directly re-use existing one from old
   * bmain, we do a full read of the new id from the memfile, and then fully swap its content
   * with the old id. This allows us to keep the same pointer even for modified data, which
   * helps reducing further detected changes by the depsgraph (since unchanged IDs remain fully
   * unchanged, even if they are using/pointing to a changed one). */
  BLI_assert((fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0);
  BLI_assert(id_old != NULL);

  const short idcode = GS(id->name);

  /* XXX 3DCursor (witch is UI data and as such should not be affected by undo) is stored in
   * Scene... So this requires some special handling, previously done in `blo_lib_link_restore()`,
   * but this cannot work anymore when we overwrite existing memory... */
  if (idcode == ID_SCE) {
    Scene *scene_old = (Scene *)id_old;
    Scene *scene = (Scene *)id;
    SWAP(View3DCursor, scene_old->cursor, scene->cursor);
  }

  Main *old_bmain = fd->old_mainlist->first;
  ListBase *old_lb = which_libbase(old_bmain, idcode);
  ListBase *new_lb = which_libbase(main, idcode);
  BLI_remlink(old_lb, id_old);
  BLI_remlink(new_lb, id);

  /* We do not need any remapping from this call here, since no ID pointer is valid in the data
   * currently (they are all pointing to old addresses, and need to go through `lib_link`
   * process). So we can pass NULL for the Main pointer parameter. */
  BKE_lib_id_swap_full(NULL, id, id_old);

  BLI_addtail(new_lb, id_old);
  BLI_addtail(old_lb, id);
}
/* For undo, store changed datablock at old address. */
For undo, store changed datablock at old address.
For undo store changed datablock at old address .
static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main, ID *id, ID *id_old)
{
  BLI_assert((fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0);
  BLI_assert(id_old != NULL);
  const short idcode = GS(id->name);
  if (idcode == ID_SCE) {
    Scene *scene_old = (Scene *)id_old;
    Scene *scene = (Scene *)id;
    SWAP(View3DCursor, scene_old->cursor, scene->cursor);
  }
  Main *old_bmain = fd->old_mainlist->first;
  ListBase *old_lb = which_libbase(old_bmain, idcode);
  ListBase *new_lb = which_libbase(main, idcode);
  BLI_remlink(old_lb, id_old);
  BLI_remlink(new_lb, id);
  BKE_lib_id_swap_full(NULL, id, id_old);
  BLI_addtail(new_lb, id_old);
  BLI_addtail(old_lb, id);
}
static void read_libblock_undo_restore_at_old_address ( FileData * fd , Main * main , ID * id , ID * id_old ) { BLI_assert ( ( fd -> skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN ) == 0 ) ; BLI_assert ( id_old != NULL ) ; const short idcode = GS ( id -> name ) ; if ( idcode == ID_SCE ) { Scene * scene_old = ( Scene * ) id_old ; Scene * scene = ( Scene * ) id ; SWAP ( View3DCursor , scene_old -> cursor , scene -> cursor ) ; } Main * old_bmain = fd -> old_mainlist -> first ; ListBase * old_lb = which_libbase ( old_bmain , idcode ) ; ListBase * new_lb = which_libbase ( main , idcode ) ; BLI_remlink ( old_lb , id_old ) ; BLI_remlink ( new_lb , id ) ; BKE_lib_id_swap_full ( NULL , id , id_old ) ; BLI_addtail ( new_lb , id_old ) ; BLI_addtail ( old_lb , id ) ; }
For undo, store changed datablock at old address.
For undo store changed datablock at old address .
/* During memfile undo, if an ID changed and we cannot directly re-use existing one from old
   * bmain, we do a full read of the new id from the memfile, and then fully swap its content
   * with the old id. This allows us to keep the same pointer even for modified data, which
   * helps reducing further detected changes by the depsgraph (since unchanged IDs remain fully
   * unchanged, even if they are using/pointing to a changed one). */ /* XXX 3DCursor (witch is UI data and as such should not be affected by undo) is stored in
   * Scene... So this requires some special handling, previously done in `blo_lib_link_restore()`,
   * but this cannot work anymore when we overwrite existing memory... */ /* We do not need any remapping from this call here, since no ID pointer is valid in the data
   * currently (they are all pointing to old addresses, and need to go through `lib_link`
   * process). So we can pass NULL for the Main pointer parameter. */