Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| #else | #else | ||||
| UNUSED_VARS(is_startup_file, reset_app_template); | UNUSED_VARS(is_startup_file, reset_app_template); | ||||
| #endif /* WITH_PYTHON */ | #endif /* WITH_PYTHON */ | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| if (use_userdef) { | if (use_userdef) { | ||||
| if (is_factory_startup) { | if (is_factory_startup) { | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST); | ||||
| } | } | ||||
| } | } | ||||
| if (use_data) { | if (use_data) { | ||||
| /* important to do before NULL'ing the context */ | /* important to do before NULL'ing the context */ | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_VERSION_UPDATE); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_VERSION_UPDATE); | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_POST); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_POST); | ||||
| if (is_factory_startup) { | if (is_factory_startup) { | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST); | ||||
| } | } | ||||
| } | } | ||||
| if (use_data) { | if (use_data) { | ||||
| WM_operatortype_last_properties_clear_all(); | WM_operatortype_last_properties_clear_all(); | ||||
| /* After load post, so for example the driver namespace can be filled | /* After load post, so for example the driver namespace can be filled | ||||
| * before evaluating the depsgraph. */ | * before evaluating the depsgraph. */ | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0); | const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0); | ||||
| bool success = false; | bool success = false; | ||||
| /* so we can get the error message */ | /* so we can get the error message */ | ||||
| errno = 0; | errno = 0; | ||||
| WM_cursor_wait(1); | WM_cursor_wait(1); | ||||
| BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE); | BKE_callback_exec(CTX_data_main(C), NULL, BKE_CB_EVT_LOAD_PRE); | ||||
| BLI_timer_on_file_load(); | BLI_timer_on_file_load(); | ||||
| UI_view2d_zoom_cache_reset(); | UI_view2d_zoom_cache_reset(); | ||||
| /* first try to append data from exotic file formats... */ | /* first try to append data from exotic file formats... */ | ||||
| /* it throws error box when file doesn't exist and returns -1 */ | /* it throws error box when file doesn't exist and returns -1 */ | ||||
| /* note; it should set some error message somewhere... (ton) */ | /* note; it should set some error message somewhere... (ton) */ | ||||
| const int retval = wm_read_exotic(filepath); | const int retval = wm_read_exotic(filepath); | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | |||||
| /* options exclude eachother */ | /* options exclude eachother */ | ||||
| BLI_assert((use_factory_settings && filepath_startup_override) == 0); | BLI_assert((use_factory_settings && filepath_startup_override) == 0); | ||||
| if ((G.f & G_FLAG_SCRIPT_OVERRIDE_PREF) == 0) { | if ((G.f & G_FLAG_SCRIPT_OVERRIDE_PREF) == 0) { | ||||
| SET_FLAG_FROM_TEST(G.f, (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0, G_FLAG_SCRIPT_AUTOEXEC); | SET_FLAG_FROM_TEST(G.f, (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0, G_FLAG_SCRIPT_AUTOEXEC); | ||||
| } | } | ||||
| if (use_data) { | if (use_data) { | ||||
| BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE); | BKE_callback_exec(CTX_data_main(C), NULL, BKE_CB_EVT_LOAD_PRE); | ||||
| BLI_timer_on_file_load(); | BLI_timer_on_file_load(); | ||||
| G.relbase_valid = 0; | G.relbase_valid = 0; | ||||
| /* put aside screens to match with persistent windows later */ | /* put aside screens to match with persistent windows later */ | ||||
| wm_window_match_init(C, &wmbase); | wm_window_match_init(C, &wmbase); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| if (BLI_path_cmp(li->filepath, filepath) == 0) { | if (BLI_path_cmp(li->filepath, filepath) == 0) { | ||||
| BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath); | BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath); | ||||
| return ok; | return ok; | ||||
| } | } | ||||
| } | } | ||||
| /* Call pre-save callbacks before writing preview, | /* Call pre-save callbacks before writing preview, | ||||
| * that way you can generate custom file thumbnail. */ | * that way you can generate custom file thumbnail. */ | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_PRE); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_PRE); | ||||
| /* Enforce full override check/generation on file save. */ | /* Enforce full override check/generation on file save. */ | ||||
| BKE_main_override_library_operations_create(bmain, true); | BKE_main_override_library_operations_create(bmain, true); | ||||
| /* blend file thumbnail */ | /* blend file thumbnail */ | ||||
| /* Save before exit_editmode, otherwise derivedmeshes for shared data corrupt T27765. */ | /* Save before exit_editmode, otherwise derivedmeshes for shared data corrupt T27765. */ | ||||
| /* Main now can store a '.blend' thumbnail, useful for background mode | /* Main now can store a '.blend' thumbnail, useful for background mode | ||||
| * or thumbnail customization. */ | * or thumbnail customization. */ | ||||
| Show All 36 Lines | |||||
| SET_FLAG_FROM_TEST(G.fileflags, fileflags & G_FILE_COMPRESS, G_FILE_COMPRESS); | SET_FLAG_FROM_TEST(G.fileflags, fileflags & G_FILE_COMPRESS, G_FILE_COMPRESS); | ||||
| /* prevent background mode scripts from clobbering history */ | /* prevent background mode scripts from clobbering history */ | ||||
| if (do_history) { | if (do_history) { | ||||
| wm_history_file_update(); | wm_history_file_update(); | ||||
| } | } | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_POST); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_POST); | ||||
| /* run this function after because the file cant be written before the blend is */ | /* run this function after because the file cant be written before the blend is */ | ||||
| if (ibuf_thumb) { | if (ibuf_thumb) { | ||||
| IMB_thumb_delete(filepath, THB_FAIL); /* without this a failed thumb overrides */ | IMB_thumb_delete(filepath, THB_FAIL); /* without this a failed thumb overrides */ | ||||
| ibuf_thumb = IMB_thumb_create(filepath, THB_LARGE, THB_SOURCE_BLEND, ibuf_thumb); | ibuf_thumb = IMB_thumb_create(filepath, THB_LARGE, THB_SOURCE_BLEND, ibuf_thumb); | ||||
| } | } | ||||
| /* Success. */ | /* Success. */ | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| const char *app_template = U.app_template[0] ? U.app_template : NULL; | const char *app_template = U.app_template[0] ? U.app_template : NULL; | ||||
| const char *const cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, app_template); | const char *const cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, app_template); | ||||
| if (cfgdir == NULL) { | if (cfgdir == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Unable to create user config path"); | BKE_report(op->reports, RPT_ERROR, "Unable to create user config path"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_PRE); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_PRE); | ||||
| /* check current window and close it if temp */ | /* check current window and close it if temp */ | ||||
| if (win && WM_window_is_temp_screen(win)) { | if (win && WM_window_is_temp_screen(win)) { | ||||
| wm_window_close(C, wm, win); | wm_window_close(C, wm, win); | ||||
| } | } | ||||
| /* update keymaps in user preferences */ | /* update keymaps in user preferences */ | ||||
| WM_keyconfig_update(wm); | WM_keyconfig_update(wm); | ||||
| Show All 11 Lines | |||||
| printf("fail\n"); | printf("fail\n"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| printf("ok\n"); | printf("ok\n"); | ||||
| G.save_over = 0; | G.save_over = 0; | ||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_SAVE_POST); | BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_POST); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void WM_OT_save_homefile(wmOperatorType *ot) | void WM_OT_save_homefile(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Save Startup File"; | ot->name = "Save Startup File"; | ||||
| ot->idname = "WM_OT_save_homefile"; | ot->idname = "WM_OT_save_homefile"; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||