diff options
Diffstat (limited to 'source/blender/blenkernel/intern/blendfile.c')
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index cc992a4a520..935000e3b8e 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -113,6 +113,7 @@ static void setup_app_data( bContext *C, BlendFileData *bfd, const char *filepath, ReportList *reports) { + Main *bmain = G.main; /* Valid usage */ Scene *curscene = NULL; const bool is_startup = (bfd->filename[0] == '\0'); const bool recover = (G.fileflags & G_FILE_RECOVER) != 0; @@ -167,8 +168,8 @@ static void setup_app_data( bool track_undo_scene; /* comes from readfile.c */ - SWAP(ListBase, G.main->wm, bfd->main->wm); - SWAP(ListBase, G.main->screen, bfd->main->screen); + SWAP(ListBase, bmain->wm, bfd->main->wm); + SWAP(ListBase, bmain->screen, bfd->main->screen); /* we re-use current screen */ curscreen = CTX_wm_screen(C); @@ -221,9 +222,9 @@ static void setup_app_data( /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - G.main = bfd->main; + bmain = G.main = bfd->main; - CTX_data_main_set(C, G.main); + CTX_data_main_set(C, bmain); if (bfd->user) { /* only here free userdef themes... */ @@ -250,7 +251,7 @@ static void setup_app_data( /* Keep state from preferences. */ const int fileflags_skip = G_FILE_FLAGS_RUNTIME; G.fileflags = (G.fileflags & fileflags_skip) | (bfd->fileflags & ~fileflags_skip); - CTX_wm_manager_set(C, G.main->wm.first); + CTX_wm_manager_set(C, bmain->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscene); CTX_wm_area_set(C, NULL); @@ -262,10 +263,10 @@ static void setup_app_data( /* this can happen when active scene was lib-linked, and doesn't exist anymore */ if (CTX_data_scene(C) == NULL) { /* in case we don't even have a local scene, add one */ - if (!G.main->scene.first) - BKE_scene_add(G.main, "Empty"); + if (!bmain->scene.first) + BKE_scene_add(bmain, "Empty"); - CTX_data_scene_set(C, G.main->scene.first); + CTX_data_scene_set(C, bmain->scene.first); CTX_wm_screen(C)->scene = CTX_data_scene(C); curscene = CTX_data_scene(C); } @@ -289,30 +290,30 @@ static void setup_app_data( /* FIXME: this version patching should really be part of the file-reading code, * but we still get too many unrelated data-corruption crashes otherwise... */ - if (G.main->versionfile < 250) - do_versions_ipos_to_animato(G.main); + if (bmain->versionfile < 250) + do_versions_ipos_to_animato(bmain); - G.main->recovered = 0; + bmain->recovered = 0; /* startup.blend or recovered startup */ if (bfd->filename[0] == 0) { - G.main->name[0] = 0; + bmain->name[0] = '\0'; } else if (recover && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */ filepath = bfd->filename; - G.main->recovered = 1; + bmain->recovered = 1; /* these are the same at times, should never copy to the same location */ - if (G.main->name != filepath) - BLI_strncpy(G.main->name, filepath, FILE_MAX); + if (bmain->name != filepath) + BLI_strncpy(bmain->name, filepath, FILE_MAX); } /* baseflags, groups, make depsgraph, etc */ /* first handle case if other windows have different scenes visible */ if (mode == LOAD_UI) { - wmWindowManager *wm = G.main->wm.first; + wmWindowManager *wm = bmain->wm.first; if (wm) { wmWindow *win; @@ -320,15 +321,15 @@ static void setup_app_data( for (win = wm->windows.first; win; win = win->next) { if (win->screen && win->screen->scene) /* zealous check... */ if (win->screen->scene != curscene) - BKE_scene_set_background(G.main, win->screen->scene); + BKE_scene_set_background(bmain, win->screen->scene); } } } - BKE_scene_set_background(G.main, curscene); + BKE_scene_set_background(bmain, curscene); if (mode != LOAD_UNDO) { RE_FreeAllPersistentData(); - IMB_colormanagement_check_file_config(G.main); + IMB_colormanagement_check_file_config(bmain); } MEM_freeN(bfd); @@ -406,9 +407,10 @@ bool BKE_blendfile_read_from_memfile( bContext *C, struct MemFile *memfile, ReportList *reports, int skip_flags) { + Main *bmain = CTX_data_main(C); BlendFileData *bfd; - bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports, skip_flags); + bfd = BLO_read_from_memfile(bmain, BKE_main_blendfile_path(bmain), memfile, reports, skip_flags); if (bfd) { /* remove the unused screens and wm */ while (bfd->main->wm.first) |