Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/blendfile.c
| Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | if (mode != LOAD_UI) { | ||||
| * This means users can have 2+ windows open and undo in both without screens switching. | * This means users can have 2+ windows open and undo in both without screens switching. | ||||
| * But if they close one of the screens, | * But if they close one of the screens, | ||||
| * undo will ensure that the scene being operated on will be activated | * undo will ensure that the scene being operated on will be activated | ||||
| * (otherwise we'd be undoing on an off-screen scene which isn't acceptable). | * (otherwise we'd be undoing on an off-screen scene which isn't acceptable). | ||||
| * see: T43424 | * see: T43424 | ||||
| */ | */ | ||||
| wmWindow *win; | wmWindow *win; | ||||
| bScreen *curscreen = NULL; | bScreen *curscreen = NULL; | ||||
| SceneLayer *cur_render_layer; | ViewLayer *cur_view_layer; | ||||
| bool track_undo_scene; | bool track_undo_scene; | ||||
| /* comes from readfile.c */ | /* comes from readfile.c */ | ||||
| SWAP(ListBase, G.main->wm, bfd->main->wm); | SWAP(ListBase, G.main->wm, bfd->main->wm); | ||||
| SWAP(ListBase, G.main->workspaces, bfd->main->workspaces); | SWAP(ListBase, G.main->workspaces, bfd->main->workspaces); | ||||
| SWAP(ListBase, G.main->screen, bfd->main->screen); | SWAP(ListBase, G.main->screen, bfd->main->screen); | ||||
| /* we re-use current window and screen */ | /* we re-use current window and screen */ | ||||
| win = CTX_wm_window(C); | win = CTX_wm_window(C); | ||||
| curscreen = CTX_wm_screen(C); | curscreen = CTX_wm_screen(C); | ||||
| /* but use Scene pointer from new file */ | /* but use Scene pointer from new file */ | ||||
| curscene = bfd->curscene; | curscene = bfd->curscene; | ||||
| cur_render_layer = bfd->cur_render_layer; | cur_view_layer = bfd->cur_view_layer; | ||||
| track_undo_scene = (mode == LOAD_UNDO && curscreen && curscene && bfd->main->wm.first); | track_undo_scene = (mode == LOAD_UNDO && curscreen && curscene && bfd->main->wm.first); | ||||
| if (curscene == NULL) { | if (curscene == NULL) { | ||||
| curscene = bfd->main->scene.first; | curscene = bfd->main->scene.first; | ||||
| } | } | ||||
| /* empty file, we add a scene to make Blender work */ | /* empty file, we add a scene to make Blender work */ | ||||
| if (curscene == NULL) { | if (curscene == NULL) { | ||||
| curscene = BKE_scene_add(bfd->main, "Empty"); | curscene = BKE_scene_add(bfd->main, "Empty"); | ||||
| } | } | ||||
| if (cur_render_layer == NULL) { | if (cur_view_layer == NULL) { | ||||
| /* fallback to scene layer */ | /* fallback to scene layer */ | ||||
| cur_render_layer = BKE_scene_layer_from_scene_get(curscene); | cur_view_layer = BKE_view_layer_from_scene_get(curscene); | ||||
| } | } | ||||
| if (track_undo_scene) { | if (track_undo_scene) { | ||||
| /* keep the old (free'd) scene, let 'blo_lib_link_screen_restore' | /* keep the old (free'd) scene, let 'blo_lib_link_screen_restore' | ||||
| * replace it with 'curscene' if its needed */ | * replace it with 'curscene' if its needed */ | ||||
| } | } | ||||
| /* and we enforce curscene to be in current screen */ | /* and we enforce curscene to be in current screen */ | ||||
| else if (win) { /* can run in bgmode */ | else if (win) { /* can run in bgmode */ | ||||
| win->scene = curscene; | win->scene = curscene; | ||||
| } | } | ||||
| /* BKE_blender_globals_clear will free G.main, here we can still restore pointers */ | /* BKE_blender_globals_clear will free G.main, here we can still restore pointers */ | ||||
| blo_lib_link_restore(bfd->main, CTX_wm_manager(C), curscene, cur_render_layer); | blo_lib_link_restore(bfd->main, CTX_wm_manager(C), curscene, cur_view_layer); | ||||
| if (win) { | if (win) { | ||||
| curscene = win->scene; | curscene = win->scene; | ||||
| } | } | ||||
| if (track_undo_scene) { | if (track_undo_scene) { | ||||
| wmWindowManager *wm = bfd->main->wm.first; | wmWindowManager *wm = bfd->main->wm.first; | ||||
| if (wm_scene_is_visible(wm, bfd->curscene) == false) { | if (wm_scene_is_visible(wm, bfd->curscene) == false) { | ||||
| curscene = bfd->curscene; | curscene = bfd->curscene; | ||||
| ▲ Show 20 Lines • Show All 495 Lines • Show Last 20 Lines | |||||