From a279bbbee56ff941ab4ffc263027a7e154703e93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 13 May 2019 13:25:51 +1000 Subject: Preferences: support loading factory preferences Previously it was only possible to load factory startup & preferences. --- source/blender/blenkernel/intern/blendfile.c | 4 +++- source/blender/windowmanager/intern/wm_files.c | 11 ++++++++++- source/blender/windowmanager/intern/wm_operators.c | 1 + source/blender/windowmanager/wm_files.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 160ac36fb61..570c1b9bd4c 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -438,7 +438,9 @@ bool BKE_blendfile_read_from_memory(bContext *C, bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports); if (bfd) { if (update_defaults) { - BLO_update_defaults_startup_blend(bfd->main, NULL); + if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) { + BLO_update_defaults_startup_blend(bfd->main, NULL); + } } setup_app_blend_file_data(C, bfd, "", params, reports); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 66406d95d75..0dc144ff0d7 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1767,7 +1767,7 @@ static int wm_userpref_read_exec(bContext *C, wmOperator *op) { const bool use_data = false; const bool use_userdef = true; - const bool use_factory_settings = false; /* TODO, support this. */ + const bool use_factory_settings = STREQ(op->type->idname, "WM_OT_read_factory_userpref"); UserDef U_backup = U; @@ -1810,6 +1810,15 @@ void WM_OT_read_userpref(wmOperatorType *ot) ot->exec = wm_userpref_read_exec; } +void WM_OT_read_factory_userpref(wmOperatorType *ot) +{ + ot->name = "Load Factory Preferences"; + ot->idname = "WM_OT_read_factory_userpref"; + + ot->invoke = WM_operator_confirm; + ot->exec = wm_userpref_read_exec; +} + static int wm_history_file_read_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { ED_file_read_bookmarks(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 964e35f8584..98b79fc75ce 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3505,6 +3505,7 @@ void wm_operatortypes_register(void) WM_operatortype_append(WM_OT_save_homefile); WM_operatortype_append(WM_OT_save_userpref); WM_operatortype_append(WM_OT_read_userpref); + WM_operatortype_append(WM_OT_read_factory_userpref); WM_operatortype_append(WM_OT_userpref_autoexec_path_add); WM_operatortype_append(WM_OT_userpref_autoexec_path_remove); WM_operatortype_append(WM_OT_window_fullscreen_toggle); diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index 388c9182f59..24209504a07 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -45,6 +45,7 @@ void WM_OT_userpref_autoexec_path_add(struct wmOperatorType *ot); void WM_OT_userpref_autoexec_path_remove(struct wmOperatorType *ot); void WM_OT_save_userpref(struct wmOperatorType *ot); void WM_OT_read_userpref(struct wmOperatorType *ot); +void WM_OT_read_factory_userpref(struct wmOperatorType *ot); void WM_OT_read_history(struct wmOperatorType *ot); void WM_OT_read_homefile(struct wmOperatorType *ot); void WM_OT_read_factory_settings(struct wmOperatorType *ot); -- cgit v1.2.3