diff options
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 16 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_driver.c | 8 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 11 |
3 files changed, 33 insertions, 2 deletions
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 17dafc4ac52..2edb0aee783 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -219,6 +219,12 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void return 0; } +static PyObject *bpy_app_global_flag_get(PyObject *UNUSED(self), void *closure) +{ + const int flag = GET_INT_FROM_POINTER(closure); + return PyBool_FromLong(G.f & flag); +} + PyDoc_STRVAR(bpy_app_tempdir_doc, "String, the temp directory used by blender (read-only)" ); @@ -243,6 +249,11 @@ static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(cl return bpy_pydriver_Dict; } +static PyObject *bpy_app_autoexec_fail_message_get(PyObject *UNUSED(self), void *UNUSED(closure)) +{ + return PyC_UnicodeFromByte(G.autoexec_fail); +} + static PyGetSetDef bpy_app_getsets[] = { {(char *)"debug", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG}, @@ -256,6 +267,11 @@ static PyGetSetDef bpy_app_getsets[] = { {(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL}, {(char *)"tempdir", bpy_app_tempdir_get, NULL, (char *)bpy_app_tempdir_doc, NULL}, {(char *)"driver_namespace", bpy_app_driver_dict_get, NULL, (char *)bpy_app_driver_dict_doc, NULL}, + + /* security */ + {(char *)"autoexec_fail", bpy_app_global_flag_get, NULL, NULL, (void *)G_SCRIPT_AUTOEXEC_FAIL}, + {(char *)"autoexec_fail_quiet", bpy_app_global_flag_get, NULL, NULL, (void *)G_SCRIPT_AUTOEXEC_FAIL_QUIET}, + {(char *)"autoexec_fail_message", bpy_app_autoexec_fail_message_get, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL} }; diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 72bfda89b64..e7c0b7b8811 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -37,6 +37,7 @@ #include "BLI_listbase.h" #include "BLI_math_base.h" +#include "BLI_string.h" #include "BKE_fcurve.h" #include "BKE_global.h" @@ -189,7 +190,12 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime) return 0.0f; if (!(G.f & G_SCRIPT_AUTOEXEC)) { - printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression); + if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) { + G.f |= G_SCRIPT_AUTOEXEC_FAIL; + BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", driver->expression); + + printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression); + } return 0.0f; } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 75827ce8bbf..c39168779fd 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -398,6 +398,10 @@ void BPY_python_end(void) void BPY_python_reset(bContext *C) { + /* unrelated security stuff */ + G.f &= ~(G_SCRIPT_AUTOEXEC_FAIL | G_SCRIPT_AUTOEXEC_FAIL_QUIET); + G.autoexec_fail[0] = '\0'; + BPY_driver_reset(); BPY_app_handlers_reset(false); BPY_modules_load_user(C); @@ -725,7 +729,12 @@ void BPY_modules_load_user(bContext *C) for (text = bmain->text.first; text; text = text->id.next) { if (text->flags & TXT_ISSCRIPT && BLI_testextensie(text->id.name + 2, ".py")) { if (!(G.f & G_SCRIPT_AUTOEXEC)) { - printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2); + if (!(G.f & G_SCRIPT_AUTOEXEC_FAIL_QUIET)) { + G.f |= G_SCRIPT_AUTOEXEC_FAIL; + BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Register Text '%s'", text->id.name + 2); + + printf("scripts disabled for \"%s\", skipping '%s'\n", bmain->name, text->id.name + 2); + } } else { PyObject *module = bpy_text_import(text); |