[Bf-blender-cvs] [71ce415] master: Fix T41462: "Reload from trusted" button not prompting for confirmation.

Bastien Montagne noreply at git.blender.org
Mon Aug 18 14:17:04 CEST 2014


Commit: 71ce415f4a48cf8915ba921594c96c09b54191a3
Author: Bastien Montagne
Date:   Mon Aug 18 12:43:08 2014 +0200
Branches: master
https://developer.blender.org/rB71ce415f4a48cf8915ba921594c96c09b54191a3

Fix T41462: "Reload from trusted" button not prompting for confirmation.

Made 'revert_mainfile' op also handle the 'use scripts' option, and use it
for this feature (since it has a nice simple invoke confirmation popup).

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

M	release/scripts/startup/bl_ui/space_info.py
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py
index ddb8331..cecddb8 100644
--- a/release/scripts/startup/bl_ui/space_info.py
+++ b/release/scripts/startup/bl_ui/space_info.py
@@ -57,11 +57,9 @@ class INFO_HT_header(Header):
         row = layout.row(align=True)
 
         if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False:
-            layout.operator_context = 'EXEC_DEFAULT'
             row.label("Auto-run disabled: %s" % bpy.app.autoexec_fail_message, icon='ERROR')
             if bpy.data.is_saved:
-                props = row.operator("wm.open_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
-                props.filepath = bpy.data.filepath
+                props = row.operator("wm.revert_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
                 props.use_scripts = True
 
             row.operator("script.autoexec_warn_clear", text="Ignore")
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index fea4056..2730442 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2376,8 +2376,8 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
 	WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_OPENFILE,
 	                               WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
 
-	RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file");
-	RNA_def_boolean(ot->srna, "use_scripts", 1, "Trusted Source",
+	RNA_def_boolean(ot->srna, "load_ui", true, "Load UI", "Load user interface setup in the .blend file");
+	RNA_def_boolean(ot->srna, "use_scripts", true, "Trusted Source",
 	                "Allow .blend file to execute scripts automatically, default available from system preferences");
 }
 
@@ -2388,7 +2388,14 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
 {
 	bool success;
 
-	success = wm_file_read_opwrap(C, G.main->name, op->reports, true);
+	wm_open_init_use_scripts(op, false);
+
+	if (RNA_boolean_get(op->ptr, "use_scripts"))
+		G.f |= G_SCRIPT_AUTOEXEC;
+	else
+		G.f &= ~G_SCRIPT_AUTOEXEC;
+
+	success = wm_file_read_opwrap(C, G.main->name, op->reports, !(G.f & G_SCRIPT_AUTOEXEC));
 
 	if (success) {
 		return OPERATOR_FINISHED;
@@ -2410,6 +2417,9 @@ static void WM_OT_revert_mainfile(wmOperatorType *ot)
 	ot->description = "Reload the saved file";
 	ot->invoke = WM_operator_confirm;
 
+	RNA_def_boolean(ot->srna, "use_scripts", true, "Trusted Source",
+	                "Allow .blend file to execute scripts automatically, default available from system preferences");
+
 	ot->exec = wm_revert_mainfile_exec;
 	ot->poll = wm_revert_mainfile_poll;
 }




More information about the Bf-blender-cvs mailing list