diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-22 07:05:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-22 07:20:53 +0300 |
commit | fc0312f538acc6411965cb664f8a5744d274e188 (patch) | |
tree | 159aa8cffd9b2afc6e64c2d97cdd7cb3eb87e7f2 /source/blender/windowmanager | |
parent | ed9273b08b9a6c0651f74ed9fe267d5ecf66d4c4 (diff) |
WM: call wm_file_read_post after resetting preferences
Also avoid diverging code paths for loading startup & preferences.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 97 |
1 files changed, 57 insertions, 40 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index c9c14dbaf23..529492470f7 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -490,18 +490,21 @@ void wm_file_read_report(bContext *C, Main *bmain) static void wm_file_read_post(bContext *C, const bool is_startup_file, const bool is_factory_startup, + const bool use_data, + const bool UNUSED(use_userdef), const bool reset_app_template) { bool addons_loaded = false; wmWindowManager *wm = CTX_wm_manager(C); - if (!G.background) { - /* remove windows which failed to be added via WM_check */ - wm_window_ghostwindows_remove_invalid(C, wm); + if (use_data) { + if (!G.background) { + /* remove windows which failed to be added via WM_check */ + wm_window_ghostwindows_remove_invalid(C, wm); + } + CTX_wm_window_set(C, wm->windows.first); } - CTX_wm_window_set(C, wm->windows.first); - #ifdef WITH_PYTHON if (is_startup_file) { /* possible python hasn't been initialized */ @@ -515,41 +518,48 @@ static void wm_file_read_post(bContext *C, /* sync addons, these may have changed from the defaults */ BPY_execute_string(C, (const char *[]){"addon_utils", NULL}, "addon_utils.reset_all()"); } - BPY_python_reset(C); + if (use_data) { + BPY_python_reset(C); + } addons_loaded = true; } } else { /* run any texts that were loaded in and flagged as modules */ - BPY_python_reset(C); + if (use_data) { + BPY_python_reset(C); + } addons_loaded = true; } #else UNUSED_VARS(is_startup_file, reset_app_template); #endif /* WITH_PYTHON */ - WM_operatortype_last_properties_clear_all(); - - /* important to do before NULL'ing the context */ Main *bmain = CTX_data_main(C); - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE); - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST); - if (is_factory_startup) { - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST); - } - /* After load post, so for example the driver namespace can be filled - * before evaluating the depsgraph. */ - DEG_on_visible_update(bmain, true); - wm_event_do_depsgraph(C); + if (use_data) { + WM_operatortype_last_properties_clear_all(); + + /* important to do before NULL'ing the context */ + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE); + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST); + if (is_factory_startup) { + BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST); + } + + /* After load post, so for example the driver namespace can be filled + * before evaluating the depsgraph. */ + DEG_on_visible_update(bmain, true); + wm_event_do_depsgraph(C); - ED_editors_init(C); + ED_editors_init(C); #if 1 - WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL); + WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL); #else - WM_msg_publish_static(CTX_wm_message_bus(C), WM_MSG_STATICTYPE_FILE_READ); + WM_msg_publish_static(CTX_wm_message_bus(C), WM_MSG_STATICTYPE_FILE_READ); #endif + } /* report any errors. * currently disabled if addons aren't yet loaded */ @@ -557,25 +567,29 @@ static void wm_file_read_post(bContext *C, wm_file_read_report(C, bmain); } - if (!G.background) { - if (wm->undo_stack == NULL) { - wm->undo_stack = BKE_undosys_stack_create(); - } - else { - BKE_undosys_stack_clear(wm->undo_stack); + if (use_data) { + if (!G.background) { + if (wm->undo_stack == NULL) { + wm->undo_stack = BKE_undosys_stack_create(); + } + else { + BKE_undosys_stack_clear(wm->undo_stack); + } + BKE_undosys_stack_init_from_main(wm->undo_stack, bmain); + BKE_undosys_stack_init_from_context(wm->undo_stack, C); } - BKE_undosys_stack_init_from_main(wm->undo_stack, bmain); - BKE_undosys_stack_init_from_context(wm->undo_stack, C); } - if (!G.background) { - /* in background mode this makes it hard to load - * a blend file and do anything since the screen - * won't be set to a valid value again */ - CTX_wm_window_set(C, NULL); /* exits queues */ + if (use_data) { + if (!G.background) { + /* in background mode this makes it hard to load + * a blend file and do anything since the screen + * won't be set to a valid value again */ + CTX_wm_window_set(C, NULL); /* exits queues */ - /* Ensure tools are registered. */ - WM_toolsystem_init(C); + /* Ensure tools are registered. */ + WM_toolsystem_init(C); + } } } @@ -602,6 +616,8 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* we didn't succeed, now try to read Blender file */ if (retval == BKE_READ_EXOTIC_OK_BLEND) { + bool use_data = true; + bool use_userdef = false; const int G_f_orig = G.f; ListBase wmbase; @@ -640,6 +656,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) if (retval == BKE_BLENDFILE_READ_OK_USERPREFS) { /* in case a userdef is read from regular .blend */ wm_init_userdef(bmain, false); + use_userdef = true; } if (retval != BKE_BLENDFILE_READ_FAIL) { @@ -648,7 +665,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) } } - wm_file_read_post(C, false, false, false); + wm_file_read_post(C, false, false, use_data, use_userdef, false); success = true; } @@ -1041,10 +1058,10 @@ void wm_homefile_read(bContext *C, /* start with save preference untitled.blend */ G.save_over = 0; - - wm_file_read_post(C, true, is_factory_startup, reset_app_template); } + wm_file_read_post(C, true, is_factory_startup, use_data, use_userdef, reset_app_template); + if (r_is_factory_startup) { *r_is_factory_startup = is_factory_startup; } |