Fix T75920: Add object - Align to 3D cursor not working.

3DCursor is UI data (hence not expected to be affected by undo) that is
stored in actual data (Scene)... So it needs some special care during
undo.

New undo code now re-reads data into existing memory, which means
copying of 3DCursor data has to happen earlier in that case, when we
still have both old and newly read data available.
This commit is contained in:
Bastien Montagne 2020-04-21 12:52:18 +02:00
parent be7c51d076
commit c73d6162be
Notes: blender-bot 2023-02-14 03:31:57 +01:00
Referenced by issue #75920, Add object - Align to 3D cursor not working
1 changed files with 9 additions and 0 deletions

View File

@ -9581,6 +9581,15 @@ static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main,
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);