Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-06-03 06:02:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-06-03 07:46:52 +0300
commit2004f9a342da231e1e790521657e9ba14fa48868 (patch)
tree9e3b6403d23801350fa67780c9955062f34f6a45
parent45b5f4e3dff759100f3eb6155b3eb9261f1fb2f6 (diff)
Cleanup: move shared functionality to wm_file_read_pre
This matches wm_file_read_post.
-rw-r--r--source/blender/windowmanager/intern/wm_files.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index c0a1dc33dfd..c09f23f6944 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -486,6 +486,24 @@ void wm_file_read_report(bContext *C, Main *bmain)
/**
* Logic shared between #WM_file_read & #wm_homefile_read,
+ * call before loading a file.
+ * \note In the case of #WM_file_read the file may fail to load.
+ * Change here shouldn't cause user-visible changes in that case.
+ */
+static void wm_file_read_pre(bContext *C, bool use_data, bool UNUSED(use_userdef))
+{
+ if (use_data) {
+ BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE);
+ BLI_timer_on_file_load();
+ }
+
+ /* 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. */
+ UI_view2d_zoom_cache_reset();
+}
+
+/**
+ * Logic shared between #WM_file_read & #wm_homefile_read,
* updates to make after reading a file.
*/
static void wm_file_read_post(bContext *C,
@@ -611,15 +629,15 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0);
bool success = false;
+ const bool use_data = true;
+ const bool use_userdef = false;
+
/* so we can get the error message */
errno = 0;
WM_cursor_wait(1);
- BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE);
- BLI_timer_on_file_load();
-
- UI_view2d_zoom_cache_reset();
+ wm_file_read_pre(C, use_data, use_userdef);
/* first try to append data from exotic file formats... */
/* it throws error box when file doesn't exist and returns -1 */
@@ -679,8 +697,6 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
}
- const bool use_data = true;
- const bool use_userdef = false;
wm_file_read_post(C, false, false, use_data, use_userdef, false);
}
#if 0
@@ -830,18 +846,15 @@ void wm_homefile_read(bContext *C,
SET_FLAG_FROM_TEST(G.f, (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0, G_FLAG_SCRIPT_AUTOEXEC);
}
- if (use_data) {
- BKE_callback_exec_null(CTX_data_main(C), BKE_CB_EVT_LOAD_PRE);
- BLI_timer_on_file_load();
+ wm_file_read_pre(C, use_data, use_userdef);
+ if (use_data) {
G.relbase_valid = 0;
/* put aside screens to match with persistent windows later */
wm_window_match_init(C, &wmbase);
}
- UI_view2d_zoom_cache_reset();
-
filepath_startup[0] = '\0';
filepath_userdef[0] = '\0';
app_template_system[0] = '\0';