Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Context not available. | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "CLG_log.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_message.h" | #include "WM_message.h" | ||||
| Context not available. | |||||
| #include "wm_window.h" | #include "wm_window.h" | ||||
| #include "wm_event_system.h" | #include "wm_event_system.h" | ||||
| static CLG_LogRef LOG = { "wm.files" }; | |||||
| static RecentFile *wm_file_history_find(const char *filepath); | static RecentFile *wm_file_history_find(const char *filepath); | ||||
| static void wm_history_file_free(RecentFile *recent); | static void wm_history_file_free(RecentFile *recent); | ||||
| static void wm_history_file_update(void); | static void wm_history_file_update(void); | ||||
| static void wm_history_file_write(void); | static void wm_history_file_write(void); | ||||
| /* To be able to read files without windows closing, opening, moving | /* To be able to read files without windows closing, opening, moving | ||||
| * we try to prepare for worst case: | * we try to prepare for worst case: | ||||
| * - active window gets active screen from file | * - active window gets active screen from file | ||||
| Context not available. | |||||
| userdef = NULL; | userdef = NULL; | ||||
| skip_flags |= BLO_READ_SKIP_USERDEF; | skip_flags |= BLO_READ_SKIP_USERDEF; | ||||
| printf("Read prefs: %s\n", filepath_userdef); | CLOG_INFO(&LOG, 1, "Read prefs: %s", filepath_userdef); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */ | /* '*thumb_pt' needs to stay NULL to prevent a bad thumbnail from being handled */ | ||||
| fprintf(stderr, "blend_file_thumb failed to create thumbnail: %s\n", err_out); | CLOG_ERROR(&LOG, "blend_file_thumb failed to create thumbnail: %s", err_out); | ||||
| thumb = NULL; | thumb = NULL; | ||||
| } | } | ||||
| Context not available. | |||||
| BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path)); | BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path)); | ||||
| BLI_path_extension_replace(path, sizeof(path), "_crash.blend"); | BLI_path_extension_replace(path, sizeof(path), "_crash.blend"); | ||||
| if (BLO_write_file(G_MAIN, path, fileflags, NULL, NULL)) { | if (BLO_write_file(G_MAIN, path, fileflags, NULL, NULL)) { | ||||
| printf("written: %s\n", path); | CLOG_INFO(&LOG, 1, "written: %s", path); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| else { | else { | ||||
| printf("failed: %s\n", path); | CLOG_ERROR(&LOG, "failed: %s", path); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_STARTUP_FILE, NULL); | BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_STARTUP_FILE, NULL); | ||||
| printf("Writing homefile: '%s' ", filepath); | CLOG_INFO(&LOG, 1, "Writing homefile: '%s'", filepath); | ||||
| ED_editors_flush_edits(bmain, false); | ED_editors_flush_edits(bmain, false); | ||||
| Context not available. | |||||
| fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); | fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_HISTORY); | ||||
| if (BLO_write_file(bmain, filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) { | if (BLO_write_file(bmain, filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) { | ||||
| printf("fail\n"); | CLOG_ERROR(&LOG, "fail"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| printf("ok\n"); | |||||
| G.save_over = 0; | G.save_over = 0; | ||||
| BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST); | BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST); | ||||
| Context not available. | |||||
| bool ok_write; | bool ok_write; | ||||
| BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); | BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); | ||||
| printf("Writing userprefs: '%s' ", filepath); | CLOG_INFO(&LOG, 1, "Writing userprefs: '%s'", filepath); | ||||
| if (use_template_userpref) { | if (use_template_userpref) { | ||||
| ok_write = BKE_blendfile_userdef_write_app_template(filepath, op->reports); | ok_write = BKE_blendfile_userdef_write_app_template(filepath, op->reports); | ||||
| } | } | ||||
| Context not available. | |||||
| ok_write = BKE_blendfile_userdef_write(filepath, op->reports); | ok_write = BKE_blendfile_userdef_write(filepath, op->reports); | ||||
| } | } | ||||
| if (ok_write) { | if (!ok_write) { | ||||
| printf("ok\n"); | CLOG_ERROR(&LOG, "fail"); | ||||
| } | |||||
| else { | |||||
| printf("fail\n"); | |||||
| ok = false; | ok = false; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| /* Also save app-template prefs */ | /* Also save app-template prefs */ | ||||
| BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); | BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); | ||||
| printf("Writing userprefs app-template: '%s' ", filepath); | CLOG_INFO(&LOG, 1, "Writing userprefs app-template: '%s'", filepath); | ||||
| if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { | if (!BKE_blendfile_userdef_write(filepath, op->reports) != 0) { | ||||
| printf("ok\n"); | CLOG_ERROR(&LOG, "fail"); | ||||
| } | |||||
| else { | |||||
| printf("fail\n"); | |||||
| ok = false; | ok = false; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||