Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Show First 20 Lines • Show All 590 Lines • ▼ Show 20 Lines | static void wm_file_read_pre(bContext *C, bool use_data, bool UNUSED(use_userdef)) | ||||
| } | } | ||||
| /* Always do this as both startup and preferences may have loaded in many font's | /* Always do this as both startup and preferences may have loaded in many font's | ||||
| * at a different zoom level to the file being loaded. */ | * at a different zoom level to the file being loaded. */ | ||||
| UI_view2d_zoom_cache_reset(); | UI_view2d_zoom_cache_reset(); | ||||
| } | } | ||||
| /** | /** | ||||
| * Parameters for #wm_file_read_post, also used for deferred initialization. | |||||
| */ | |||||
| struct wmFileReadPost_Params { | |||||
| uint use_data : 1; | |||||
| uint use_userdef : 1; | |||||
| uint is_startup_file : 1; | |||||
| uint is_factory_startup : 1; | |||||
| uint reset_app_template : 1; | |||||
| }; | |||||
| /** | |||||
| * Logic shared between #WM_file_read & #wm_homefile_read, | * Logic shared between #WM_file_read & #wm_homefile_read, | ||||
| * updates to make after reading a file. | * updates to make after reading a file. | ||||
| */ | */ | ||||
| static void wm_file_read_post(bContext *C, | static void wm_file_read_post(bContext *C, const struct wmFileReadPost_Params *params) | ||||
| const bool is_startup_file, | |||||
| const bool is_factory_startup, | |||||
| const bool use_data, | |||||
| const bool use_userdef, | |||||
| const bool reset_app_template) | |||||
| { | { | ||||
| bool addons_loaded = false; | |||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| const bool use_data = params->use_data; | |||||
| const bool use_userdef = params->use_userdef; | |||||
| const bool is_startup_file = params->is_startup_file; | |||||
| const bool is_factory_startup = params->is_factory_startup; | |||||
| const bool reset_app_template = params->reset_app_template; | |||||
| bool addons_loaded = false; | |||||
| if (use_data) { | if (use_data) { | ||||
| if (!G.background) { | if (!G.background) { | ||||
| /* remove windows which failed to be added via WM_check */ | /* remove windows which failed to be added via WM_check */ | ||||
| wm_window_ghostwindows_remove_invalid(C, wm); | wm_window_ghostwindows_remove_invalid(C, wm); | ||||
| } | } | ||||
| CTX_wm_window_set(C, wm->windows.first); | CTX_wm_window_set(C, wm->windows.first); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | if (bfd != NULL) { | ||||
| /* match the read WM with current WM */ | /* match the read WM with current WM */ | ||||
| wm_window_match_do(C, &wmbase, &bmain->wm, &bmain->wm); | wm_window_match_do(C, &wmbase, &bmain->wm, &bmain->wm); | ||||
| WM_check(C); /* opens window(s), checks keymaps */ | WM_check(C); /* opens window(s), checks keymaps */ | ||||
| if (do_history_file_update) { | if (do_history_file_update) { | ||||
| wm_history_file_update(); | wm_history_file_update(); | ||||
| } | } | ||||
| wm_file_read_post(C, false, false, use_data, use_userdef, false); | wm_file_read_post(C, | ||||
| &(const struct wmFileReadPost_Params){ | |||||
| .use_data = use_data, | |||||
| .use_userdef = use_userdef, | |||||
| .is_startup_file = false, | |||||
| .is_factory_startup = false, | |||||
| .reset_app_template = false, | |||||
| }); | |||||
| bf_reports.duration.whole = PIL_check_seconds_timer() - bf_reports.duration.whole; | bf_reports.duration.whole = PIL_check_seconds_timer() - bf_reports.duration.whole; | ||||
| file_read_reports_finalize(&bf_reports); | file_read_reports_finalize(&bf_reports); | ||||
| success = true; | success = true; | ||||
| } | } | ||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read Startup & Preferences Blend-File API | /** \name Read Startup & Preferences Blend-File API | ||||
| * \{ */ | * \{ */ | ||||
| /** | /** | ||||
| * Called on startup, (context entirely filled with NULLs) | * Called on startup, (context entirely filled with NULLs) | ||||
| * or called for 'New File' both `startup.blend` and `userpref.blend` are checked. | * or called for 'New File' both `startup.blend` and `userpref.blend` are checked. | ||||
| * | |||||
| * \param r_params_file_read_post: Support postponed initialization, | |||||
| * needed for initial startup when only some sub-systems have been initialized. | |||||
| * When non-null, #wm_file_read_post doesn't run, instead it's arguments are stored | |||||
| * in this return argument. | |||||
| * The caller is responsible for calling #wm_homefile_read_post with this return argument. | |||||
| */ | */ | ||||
| void wm_homefile_read_ex(bContext *C, | void wm_homefile_read_ex(bContext *C, | ||||
| const struct wmHomeFileRead_Params *params_homefile, | const struct wmHomeFileRead_Params *params_homefile, | ||||
| ReportList *reports, | ReportList *reports, | ||||
| bool *r_is_factory_startup) | struct wmFileReadPost_Params **r_params_file_read_post) | ||||
| { | { | ||||
| #if 0 /* UNUSED, keep as this may be needed later & the comment below isn't self evident. */ | #if 0 /* UNUSED, keep as this may be needed later & the comment below isn't self evident. */ | ||||
| /* Context does not always have valid main pointer here. */ | /* Context does not always have valid main pointer here. */ | ||||
| Main *bmain = G_MAIN; | Main *bmain = G_MAIN; | ||||
| #endif | #endif | ||||
| ListBase wmbase; | ListBase wmbase; | ||||
| bool success = false; | bool success = false; | ||||
| ▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | if (use_data) { | ||||
| WM_check(C); /* opens window(s), checks keymaps */ | WM_check(C); /* opens window(s), checks keymaps */ | ||||
| bmain->name[0] = '\0'; | bmain->name[0] = '\0'; | ||||
| /* start with save preference untitled.blend */ | /* start with save preference untitled.blend */ | ||||
| G.save_over = 0; | G.save_over = 0; | ||||
| } | } | ||||
| wm_file_read_post(C, true, is_factory_startup, use_data, use_userdef, reset_app_template); | { | ||||
| const struct wmFileReadPost_Params params_file_read_post = { | |||||
| if (r_is_factory_startup) { | .use_data = use_data, | ||||
| *r_is_factory_startup = is_factory_startup; | .use_userdef = use_userdef, | ||||
| .is_startup_file = true, | |||||
| .is_factory_startup = is_factory_startup, | |||||
| .reset_app_template = reset_app_template, | |||||
| }; | |||||
| if (r_params_file_read_post == NULL) { | |||||
| wm_file_read_post(C, ¶ms_file_read_post); | |||||
| } | |||||
| else { | |||||
| *r_params_file_read_post = MEM_mallocN(sizeof(struct wmFileReadPost_Params), __func__); | |||||
| **r_params_file_read_post = params_file_read_post; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| void wm_homefile_read(bContext *C, | void wm_homefile_read(bContext *C, | ||||
| const struct wmHomeFileRead_Params *params_homefile, | const struct wmHomeFileRead_Params *params_homefile, | ||||
| ReportList *reports) | ReportList *reports) | ||||
| { | { | ||||
| wm_homefile_read_ex(C, params_homefile, reports, NULL); | wm_homefile_read_ex(C, params_homefile, reports, NULL); | ||||
| } | } | ||||
| /** | |||||
| * Special case, support deferred execution of #wm_file_read_post, | |||||
| * Needed when loading for the first time to workaround order of initialization bug, see T89046. | |||||
| */ | |||||
| void wm_homefile_read_post(struct bContext *C, | |||||
| const struct wmFileReadPost_Params *params_file_read_post) | |||||
| { | |||||
| wm_file_read_post(C, params_file_read_post); | |||||
| MEM_freeN((void *)params_file_read_post); | |||||
| } | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Blend-File History API | /** \name Blend-File History API | ||||
| * \{ */ | * \{ */ | ||||
| void wm_history_file_read(void) | void wm_history_file_read(void) | ||||
| { | { | ||||
| char name[FILE_MAX]; | char name[FILE_MAX]; | ||||
| LinkNode *l, *lines; | LinkNode *l, *lines; | ||||
| ▲ Show 20 Lines • Show All 2,267 Lines • Show Last 20 Lines | |||||