From 7f47cd9b174627ef08cc642bde349b8018e87c55 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Feb 2015 21:31:36 +1100 Subject: Correct fix for T43424 Would crash undoing adding a new scene in camera view. --- source/blender/blenkernel/intern/blender.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern/blender.c') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index dda790ea700..b6ea780576e 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -258,23 +258,28 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath SWAP(ListBase, G.main->screen, bfd->main->screen); SWAP(ListBase, G.main->script, bfd->main->script); + /* we re-use current screen */ curscreen = CTX_wm_screen(C); + /* but use new Scene pointer */ + curscene = bfd->curscene; track_undo_scene = (mode == LOAD_UNDO && curscreen && bfd->main->wm.first); - if (track_undo_scene) { - curscene = curscreen->scene; - } - else { - /* but use new Scene pointer */ - curscene = bfd->curscene; - } if (curscene == NULL) curscene = bfd->main->scene.first; /* empty file, we add a scene to make Blender work */ if (curscene == NULL) curscene = BKE_scene_add(bfd->main, "Empty"); - /* and we enforce curscene to be in current screen */ - if (curscreen) curscreen->scene = curscene; /* can run in bgmode */ + if (track_undo_scene) { + /* keep the old (free'd) scene, let 'blo_lib_link_screen_restore' + * replace it with 'curscene' if its needed */ + } + else { + /* and we enforce curscene to be in current screen */ + if (curscreen) { + /* can run in bgmode */ + curscreen->scene = curscene; + } + } /* clear_global will free G.main, here we can still restore pointers */ blo_lib_link_screen_restore(bfd->main, curscreen, curscene); -- cgit v1.2.3