/* op can be NULL */ int WM_read_homefile(bContext *C, wmOperator *op) { ListBase wmbase; char tstr[FILE_MAXDIR+FILE_MAXFILE], scestr[FILE_MAXDIR]; char *home= BLI_gethome(); int from_memory= op?RNA_boolean_get(op->ptr, "factory"):0; int success; BLI_clean(home); free_ttfont(); /* still weird... what does it here? */ G.relbase_valid = 0; if (!from_memory) { BLI_make_file_string(G.sce, tstr, home, ".B25.blend"); } strcpy(scestr, G.sce); /* temporary store */ /* prevent loading no UI */ G.fileflags &= ~G_FILE_NO_UI; /* put aside screens to match with persistant windows later */ wm_window_match_init(C, &wmbase); if (!from_memory && BLI_exists(tstr)) { success = BKE_read_file(C, tstr, NULL, NULL); } else { success = BKE_read_file_from_memory(C, datatoc_B_blend, datatoc_B_blend_size, NULL, NULL); if (wmbase.first == NULL) wm_clear_default_size(C); } /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); wm_check(C); /* opens window(s), checks keymaps */ strcpy(G.sce, scestr); /* restore */ wm_init_userdef(); /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ GPU_default_lights(); /* XXX */ G.save_over = 0; // start with save preference untitled.blend G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in .B.blend... */ // mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender" // refresh_interface_font(); // undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL); CTX_wm_window_set(C, NULL); /* exits queues */ return OPERATOR_FINISHED; }
/* called in creator.c even... tsk, split this! */ void WM_exit(bContext *C) { wmWindow *win; sound_exit(); /* first wrap up running stuff, we assume only the active WM is running */ /* modal handlers are on window level freed, others too? */ /* note; same code copied in wm_files.c */ if(C && CTX_wm_manager(C)) { WM_jobs_stop_all(CTX_wm_manager(C)); for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) { CTX_wm_window_set(C, win); /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); WM_event_remove_handlers(C, &win->modalhandlers); ED_screen_exit(C, win, win->screen); } } wm_operatortype_free(); WM_menutype_free(); /* all non-screen and non-space stuff editors did, like editmode */ if(C) ED_editors_exit(C); // XXX // BIF_GlobalReebFree(); // BIF_freeRetarget(); BIF_freeTemplates(C); free_ttfont(); /* bke_font.h */ free_openrecent(); BKE_freecubetable(); fastshade_free_render(); /* shaded view */ ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ if(C && CTX_wm_manager(C)) wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */ free_blender(); /* blender.c, does entire library and spacetypes */ // free_matcopybuf(); free_anim_copybuf(); free_anim_drivers_copybuf(); free_posebuf(); // free_vertexpaint(); // free_imagepaint(); // fsmenu_free(); BLF_exit(); RE_FreeAllRender(); RE_engines_exit(); // free_txt_data(); #ifndef DISABLE_PYTHON /* XXX - old note */ /* before free_blender so py's gc happens while library still exists */ /* needed at least for a rare sigsegv that can happen in pydrivers */ /* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's * so decref'ing them after python ends causes bad problems every time * the pyDriver bug can be fixed if it happens again we can deal with it then */ BPY_end_python(); #endif libtiff_exit(); #ifdef WITH_QUICKTIME quicktime_exit(); #endif if (!G.background) { // XXX UI_filelist_free_icons(); } GPU_buffer_pool_free(0); GPU_extensions_exit(); // if (copybuf) MEM_freeN(copybuf); // if (copybufinfo) MEM_freeN(copybufinfo); BKE_undo_save_quit(); // saves quit.blend if global undo is on BKE_reset_undo(); ED_file_exit(); /* for fsmenu */ UI_exit(); BKE_userdef_free(); RNA_exit(); /* should be after BPY_end_python so struct python slots are cleared */ wm_ghost_exit(); CTX_free(C); SYS_DeleteSystem(SYS_GetSystem()); if(MEM_get_memory_blocks_in_use()!=0) { printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use()); MEM_printmemlist(); } wm_autosave_delete(); printf("\nBlender quit\n"); #ifdef WIN32 /* ask user to press enter when in debug mode */ if(G.f & G_DEBUG) { printf("press enter key to exit...\n\n"); getchar(); } #endif exit(G.afbreek==1); }
/* op can be NULL */ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory) { ListBase wmbase; char tstr[FILE_MAX]; int success = 0; free_ttfont(); /* still weird... what does it here? */ G.relbase_valid = 0; if (!from_memory) { char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL); if (cfgdir) { BLI_make_file_string(G.main->name, tstr, cfgdir, BLENDER_STARTUP_FILE); } else { tstr[0] = '\0'; from_memory = 1; } } /* prevent loading no UI */ G.fileflags &= ~G_FILE_NO_UI; /* put aside screens to match with persistent windows later */ wm_window_match_init(C, &wmbase); if (!from_memory && BLI_exists(tstr)) { success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL); if (U.themes.first == NULL) { printf("\nError: No valid "STRINGIFY (BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n"); success = 0; } } if (success == 0) { success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL); if (wmbase.first == NULL) wm_clear_default_size(C); #ifdef WITH_PYTHON_SECURITY /* not default */ /* use alternative setting for security nuts * otherwise we'd need to patch the binary blob - startup.blend.c */ U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE; #endif } /* prevent buggy files that had G_FILE_RELATIVE_REMAP written out by mistake. Screws up autosaves otherwise * can remove this eventually, only in a 2.53 and older, now its not written */ G.fileflags &= ~G_FILE_RELATIVE_REMAP; /* check userdef before open window, keymaps etc */ wm_init_userdef(C); /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); WM_check(C); /* opens window(s), checks keymaps */ G.main->name[0] = '\0'; /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ if (!G.background) GPU_default_lights(); /* XXX */ G.save_over = 0; // start with save preference untitled.blend G.fileflags &= ~G_FILE_AUTOPLAY; /* disable autoplay in startup.blend... */ // mainwindow_set_filename_to_title(""); // empty string re-initializes title to "Blender" // refresh_interface_font(); // undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ ED_editors_init(C); DAG_on_visible_update(CTX_data_main(C), TRUE); #ifdef WITH_PYTHON if (CTX_py_init_get(C)) { /* sync addons, these may have changed from the defaults */ BPY_string_exec(C, "__import__('addon_utils').reset_all()"); BPY_driver_reset(); BPY_app_handlers_reset(FALSE); BPY_modules_load_user(C); } #endif WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL); /* in background mode the scene will stay NULL */ if (!G.background) { CTX_wm_window_set(C, NULL); /* exits queues */ } return TRUE; }