[Bf-blender-cvs] [a279bbbee56] master: Preferences: support loading factory preferences

Campbell Barton noreply at git.blender.org
Mon May 13 05:26:41 CEST 2019


Commit: a279bbbee56ff941ab4ffc263027a7e154703e93
Author: Campbell Barton
Date:   Mon May 13 13:25:51 2019 +1000
Branches: master
https://developer.blender.org/rBa279bbbee56ff941ab4ffc263027a7e154703e93

Preferences: support loading factory preferences

Previously it was only possible to load factory startup & preferences.

===================================================================

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/wm_files.h

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 204afca67bb..020dca91f07 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -84,6 +84,7 @@ class USERPREF_PT_save_preferences(Panel):
         col = layout.column(align=True)
         col.operator("wm.save_userpref")
         col.operator("wm.read_userpref")
+        col.operator("wm.read_factory_userpref")
 
 
 # Panel mix-in.
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, "<memory2>", 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);



More information about the Bf-blender-cvs mailing list