Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_init_exit.c
| Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | void WM_init(bContext *C, int argc, const char **argv) | ||||
| BKE_icons_init(BIFICONID_LAST); | BKE_icons_init(BIFICONID_LAST); | ||||
| /* reports can't be initialized before the wm, | /* reports can't be initialized before the wm, | ||||
| * but keep before file reading, since that may report errors */ | * but keep before file reading, since that may report errors */ | ||||
| wm_init_reports(C); | wm_init_reports(C); | ||||
| WM_msgbus_types_init(); | WM_msgbus_types_init(); | ||||
| bool is_factory_startup = true; | |||||
| /* Studio-lights needs to be init before we read the home-file, | /* Studio-lights needs to be init before we read the home-file, | ||||
| * otherwise the versioning cannot find the default studio-light. */ | * otherwise the versioning cannot find the default studio-light. */ | ||||
| BKE_studiolight_init(); | BKE_studiolight_init(); | ||||
| BLI_assert((G.fileflags & G_FILE_NO_UI) == 0); | BLI_assert((G.fileflags & G_FILE_NO_UI) == 0); | ||||
| /** | |||||
| * NOTE(@campbellbarton): Startup file and order of initialization. | |||||
| * | |||||
| * Loading #BLENDER_STARTUP_FILE, #BLENDER_USERPREF_FILE, starting Python and other sub-systems, | |||||
| * have inter-dependencies, for example. | |||||
| * | |||||
| * - Some sub-systems depend on the preferences (initializing icons depend on the theme). | |||||
| * - Add-ons depends on the preferences to know what has been enabled. | |||||
| * - Add-ons depends on the window-manger to register their key-maps. | |||||
| * - Evaluating the startup file depends on Python for animation-drivers (see T89046). | |||||
| * - Starting Python depends on the startup file so key-maps can be added in the window-manger. | |||||
| * | |||||
| * Loading preferences early, then application subsystems and finally the startup data would | |||||
| * simplify things if it weren't for key-maps being part of the window-manager | |||||
| * which is blend file data. | |||||
| * Creating a dummy window-manager early, or moving the key-maps into the preferences | |||||
| * would resolve this and may be worth looking into long-term, see: D12184 for details. | |||||
| */ | |||||
| struct wmFileReadPost_Params *params_file_read_post = NULL; | |||||
| wm_homefile_read_ex(C, | wm_homefile_read_ex(C, | ||||
| &(const struct wmHomeFileRead_Params){ | &(const struct wmHomeFileRead_Params){ | ||||
| .use_data = true, | .use_data = true, | ||||
| .use_userdef = true, | .use_userdef = true, | ||||
| .use_factory_settings = G.factory_startup, | .use_factory_settings = G.factory_startup, | ||||
| .use_empty_data = false, | .use_empty_data = false, | ||||
| .filepath_startup_override = NULL, | .filepath_startup_override = NULL, | ||||
| .app_template_override = WM_init_state_app_template_get(), | .app_template_override = WM_init_state_app_template_get(), | ||||
| }, | }, | ||||
| NULL, | NULL, | ||||
| &is_factory_startup); | ¶ms_file_read_post); | ||||
| /* Call again to set from userpreferences... */ | /* Call again to set from userpreferences... */ | ||||
| BLT_lang_set(NULL); | BLT_lang_set(NULL); | ||||
| /* For fsMenu. Called here so can include user preference paths if needed. */ | /* For fsMenu. Called here so can include user preference paths if needed. */ | ||||
| ED_file_init(); | ED_file_init(); | ||||
| /* That one is generated on demand, we need to be sure it's clear on init. */ | /* That one is generated on demand, we need to be sure it's clear on init. */ | ||||
| Show All 13 Lines | #endif | ||||
| UI_init(); | UI_init(); | ||||
| } | } | ||||
| BKE_subdiv_init(); | BKE_subdiv_init(); | ||||
| ED_spacemacros_init(); | ED_spacemacros_init(); | ||||
| /* NOTE(campbell): there is a bug where python needs initializing before loading the | |||||
| * startup.blend because it may contain PyDrivers. It also needs to be after | |||||
| * initializing space types and other internal data. | |||||
| * | |||||
| * However can't redo this at the moment. Solution is to load python | |||||
| * before wm_homefile_read() or make py-drivers check if python is running. | |||||
| * Will try fix when the crash can be repeated. */ | |||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| BPY_python_start(C, argc, argv); | BPY_python_start(C, argc, argv); | ||||
| BPY_python_reset(C); | BPY_python_reset(C); | ||||
| #else | #else | ||||
| (void)argc; /* unused */ | (void)argc; /* unused */ | ||||
| (void)argv; /* unused */ | (void)argv; /* unused */ | ||||
| #endif | #endif | ||||
| Show All 23 Lines | |||||
| #ifdef WITH_COMPOSITOR | #ifdef WITH_COMPOSITOR | ||||
| if (1) { | if (1) { | ||||
| extern void *COM_linker_hack; | extern void *COM_linker_hack; | ||||
| COM_linker_hack = COM_execute; | COM_linker_hack = COM_execute; | ||||
| } | } | ||||
| #endif | #endif | ||||
| { | wm_homefile_read_post(C, params_file_read_post); | ||||
| Main *bmain = CTX_data_main(C); | |||||
| /* NOTE: logic here is from wm_file_read_post, | |||||
| * call functions that depend on Python being initialized. */ | |||||
| /* normally 'wm_homefile_read' will do this, | |||||
| * however python is not initialized when called from this function. | |||||
| * | |||||
| * unlikely any handlers are set but its possible, | |||||
| * note that recovering the last session does its own callbacks. */ | |||||
| CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); | |||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_VERSION_UPDATE); | |||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_POST); | |||||
| if (is_factory_startup) { | |||||
| BKE_callback_exec_null(bmain, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST); | |||||
| } | |||||
| wm_file_read_report(C, bmain); | |||||
| if (!G.background) { | |||||
| CTX_wm_window_set(C, NULL); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| void WM_init_splash(bContext *C) | void WM_init_splash(bContext *C) | ||||
| { | { | ||||
| if ((U.uiflag & USER_SPLASH_DISABLE) == 0) { | if ((U.uiflag & USER_SPLASH_DISABLE) == 0) { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *prevwin = CTX_wm_window(C); | wmWindow *prevwin = CTX_wm_window(C); | ||||
| ▲ Show 20 Lines • Show All 302 Lines • Show Last 20 Lines | |||||