diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-10 04:42:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-10 04:42:16 +0400 |
commit | 412c04347440fa5e480b69a07b20ff1399775c5b (patch) | |
tree | 6fa2ac672fdf61006bce6fa17ccc30bdcae2442f /source/blender/editors/space_script | |
parent | e7a487d1e9e79176a0ca99cda3882aac4ea16a99 (diff) |
Python script auto-execution changes:
- script execution is off by default
- if a blend file attempts to execute a script
this shows a message in the header with the action
that was suppressed (script/driver/game-autostart) and 2 buttons to either reload the file trusted, or to ignore the message.
- the file selector will always default to use the trust setting in the user preferences,
but reloading an open file will keep using the current setting (whatever was set before or set on the command-line).
- added SCons setting WITH_BF_PYTHON_SECURITY, this sets the default state for the user prefereces not to trust blend files on load.
... this option was in CMake before, but always off, now its enabled by default for SCons and CMake, and forced on in CMake for now.
Diffstat (limited to 'source/blender/editors/space_script')
-rw-r--r-- | source/blender/editors/space_script/script_edit.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_script/script_ops.c | 1 |
3 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 96008004ee4..8074ec57474 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -36,6 +36,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_global.h" #include "WM_api.h" #include "WM_types.h" @@ -110,3 +111,23 @@ void SCRIPT_OT_reload(wmOperatorType *ot) /* api callbacks */ ot->exec = script_reload_exec; } + +static int script_autoexec_warn_clear_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) +{ + G.f |= G_SCRIPT_AUTOEXEC_FAIL_QUIET; + return OPERATOR_FINISHED; +} + +void SCRIPT_OT_autoexec_warn_clear(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Continue Untrusted"; + ot->description = "Ignore autoexec warning"; + ot->idname = "SCRIPT_OT_autoexec_warn_clear"; + + /* flags */ + ot->flag = OPTYPE_INTERNAL; + + /* api callbacks */ + ot->exec = script_autoexec_warn_clear_exec; +} diff --git a/source/blender/editors/space_script/script_intern.h b/source/blender/editors/space_script/script_intern.h index 00863863994..cef6082aa1c 100644 --- a/source/blender/editors/space_script/script_intern.h +++ b/source/blender/editors/space_script/script_intern.h @@ -40,6 +40,7 @@ void script_keymap(struct wmKeyConfig *keyconf); /* script_edit.c */ void SCRIPT_OT_reload(struct wmOperatorType *ot); void SCRIPT_OT_python_file_run(struct wmOperatorType *ot); +void SCRIPT_OT_autoexec_warn_clear(struct wmOperatorType *ot); #endif /* __SCRIPT_INTERN_H__ */ diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index 57a1112a832..7398126a8e5 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -56,6 +56,7 @@ void script_operatortypes(void) { WM_operatortype_append(SCRIPT_OT_python_file_run); WM_operatortype_append(SCRIPT_OT_reload); + WM_operatortype_append(SCRIPT_OT_autoexec_warn_clear); } void script_keymap(wmKeyConfig *keyconf) |