From 71ce415f4a48cf8915ba921594c96c09b54191a3 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 18 Aug 2014 12:43:08 +0200 Subject: [PATCH] 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). --- release/scripts/startup/bl_ui/space_info.py | 4 +--- .../blender/windowmanager/intern/wm_operators.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index ddb83310fe8..cecddb86f2b 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 fea40564454..2730442096f 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; }