forked from bartvdbraak/blender
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).
This commit is contained in:
parent
dc05d817eb
commit
71ce415f4a
@ -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")
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user