Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Show First 20 Lines • Show All 930 Lines • ▼ Show 20 Lines | void wm_homefile_read(bContext *C, | ||||
| } | } | ||||
| if (!use_factory_settings || (filepath_startup[0] != '\0')) { | if (!use_factory_settings || (filepath_startup[0] != '\0')) { | ||||
| if (BLI_access(filepath_startup, R_OK) == 0) { | if (BLI_access(filepath_startup, R_OK) == 0) { | ||||
| success = BKE_blendfile_read(C, | success = BKE_blendfile_read(C, | ||||
| filepath_startup, | filepath_startup, | ||||
| &(const struct BlendFileReadParams){ | &(const struct BlendFileReadParams){ | ||||
| .is_startup = true, | .is_startup = true, | ||||
| .skip_flags = skip_flags, | .skip_flags = skip_flags | BLO_READ_SKIP_USERDEF, | ||||
| }, | }, | ||||
| NULL); | NULL); | ||||
| } | } | ||||
| if (BLI_listbase_is_empty(&U.themes)) { | if (BLI_listbase_is_empty(&U.themes)) { | ||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", | printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", | ||||
| filepath_startup); | filepath_startup); | ||||
| } | } | ||||
| Show All 10 Lines | void wm_homefile_read(bContext *C, | ||||
| } | } | ||||
| if (success == false && filepath_startup_override && reports) { | if (success == false && filepath_startup_override && reports) { | ||||
| /* We can not return from here because wm is already reset */ | /* We can not return from here because wm is already reset */ | ||||
| BKE_reportf(reports, RPT_ERROR, "Could not read '%s'", filepath_startup_override); | BKE_reportf(reports, RPT_ERROR, "Could not read '%s'", filepath_startup_override); | ||||
| } | } | ||||
| if (success == false) { | if (success == false) { | ||||
| if (use_userdef) { | |||||
| UserDef *userdef_template = BKE_blendfile_userdef_from_defaults(); | |||||
| BKE_blender_userdef_app_template_data_set_and_free(userdef_template); | |||||
| skip_flags &= ~BLO_READ_SKIP_USERDEF; | |||||
| read_userdef_from_memory = true; | |||||
| } | |||||
| success = BKE_blendfile_read_from_memory(C, | success = BKE_blendfile_read_from_memory(C, | ||||
| datatoc_startup_blend, | datatoc_startup_blend, | ||||
| datatoc_startup_blend_size, | datatoc_startup_blend_size, | ||||
| true, | true, | ||||
| &(const struct BlendFileReadParams){ | &(const struct BlendFileReadParams){ | ||||
| .is_startup = true, | .is_startup = true, | ||||
| .skip_flags = skip_flags, | .skip_flags = skip_flags, | ||||
| }, | }, | ||||
| NULL); | NULL); | ||||
| if (success) { | |||||
| if (use_userdef) { | |||||
| if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) { | |||||
| read_userdef_from_memory = true; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (use_data && BLI_listbase_is_empty(&wmbase)) { | if (use_data && BLI_listbase_is_empty(&wmbase)) { | ||||
| wm_clear_default_size(C); | wm_clear_default_size(C); | ||||
| } | } | ||||
| } | } | ||||
| if (use_empty_data) { | if (use_empty_data) { | ||||
| BKE_blendfile_read_make_empty(C); | BKE_blendfile_read_make_empty(C); | ||||
| } | } | ||||
| Show All 20 Lines | if (app_template_system[0] != '\0') { | ||||
| if (use_userdef) { | if (use_userdef) { | ||||
| UserDef *userdef_template = NULL; | UserDef *userdef_template = NULL; | ||||
| /* just avoids missing file warning */ | /* just avoids missing file warning */ | ||||
| if (BLI_exists(temp_path)) { | if (BLI_exists(temp_path)) { | ||||
| userdef_template = BKE_blendfile_userdef_read(temp_path, NULL); | userdef_template = BKE_blendfile_userdef_read(temp_path, NULL); | ||||
| } | } | ||||
| if (userdef_template == NULL) { | if (userdef_template == NULL) { | ||||
| /* we need to have preferences load to overwrite preferences from previous template */ | /* we need to have preferences load to overwrite preferences from previous template */ | ||||
| userdef_template = BKE_blendfile_userdef_read_from_memory( | userdef_template = BKE_blendfile_userdef_from_defaults(); | ||||
| datatoc_startup_blend, datatoc_startup_blend_size, NULL); | |||||
| read_userdef_from_memory = true; | read_userdef_from_memory = true; | ||||
| } | } | ||||
| if (userdef_template) { | if (userdef_template) { | ||||
| BKE_blender_userdef_app_template_data_set_and_free(userdef_template); | BKE_blender_userdef_app_template_data_set_and_free(userdef_template); | ||||
| userdef_template = NULL; | userdef_template = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 617 Lines • ▼ Show 20 Lines | static int wm_homefile_write_exec(bContext *C, wmOperator *op) | ||||
| printf("Writing homefile: '%s' ", filepath); | printf("Writing homefile: '%s' ", filepath); | ||||
| ED_editors_flush_edits(bmain, false); | ED_editors_flush_edits(bmain, false); | ||||
| /* force save as regular blend file */ | /* force save as regular blend file */ | ||||
| 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, op->reports, NULL) == 0) { | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 1,485 Lines • Show Last 20 Lines | |||||