Fix #106372: Wrong message in driver for disabled execution
When using a python expression, its execution is disabled by default unless specified differently in the user preferences. Previously this only produced the error "Error: Invalid Python expression". However that isn't really the correct error. Now the error reads "Python restricted for security". I've added a new flag to the driver `DRIVER_FLAG_PYTHON_BLOCKED` that is set if the driver can't run because python is blocked Co-authored by Phillip Oeser Pull Request: https://projects.blender.org/blender/blender/pulls/124587
This commit is contained in:
committed by
Christoph Lendenfeld
parent
780dc67f6d
commit
1a8053939b
@@ -1033,17 +1033,16 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
|
||||
col = uiLayoutColumn(layout, true);
|
||||
block = uiLayoutGetBlock(col);
|
||||
|
||||
if (driver->flag & DRIVER_FLAG_INVALID) {
|
||||
if (driver->flag & DRIVER_FLAG_PYTHON_BLOCKED) {
|
||||
/* TODO: Add button to enable? */
|
||||
uiItemL(col, RPT_("Python restricted for security"), ICON_ERROR);
|
||||
uiItemL(col, RPT_("Slow Python expression"), ICON_INFO);
|
||||
}
|
||||
else if (driver->flag & DRIVER_FLAG_INVALID) {
|
||||
uiItemL(col, RPT_("ERROR: Invalid Python expression"), ICON_CANCEL);
|
||||
}
|
||||
else if (!BKE_driver_has_simple_expression(driver)) {
|
||||
if ((G.f & G_FLAG_SCRIPT_AUTOEXEC) == 0) {
|
||||
/* TODO: Add button to enable? */
|
||||
uiItemL(col, RPT_("Python restricted for security"), ICON_ERROR);
|
||||
}
|
||||
else {
|
||||
uiItemL(col, RPT_("Slow Python expression"), ICON_INFO);
|
||||
}
|
||||
uiItemL(col, RPT_("Slow Python expression"), ICON_INFO);
|
||||
}
|
||||
|
||||
/* Explicit bpy-references are evil. Warn about these to prevent errors */
|
||||
|
||||
@@ -561,7 +561,8 @@ typedef enum eDriver_Flags {
|
||||
DRIVER_FLAG_RECOMPILE = (1 << 3),
|
||||
/** The names are cached so they don't need have python unicode versions created each time */
|
||||
DRIVER_FLAG_RENAMEVAR = (1 << 4),
|
||||
// DRIVER_FLAG_UNUSED_5 = (1 << 5),
|
||||
/* Set if the driver cannot run because it uses Python which isn't allowed to execute. */
|
||||
DRIVER_FLAG_PYTHON_BLOCKED = (1 << 5),
|
||||
/** Include 'self' in the drivers namespace. */
|
||||
DRIVER_FLAG_USE_SELF = (1 << 6),
|
||||
} eDriver_Flags;
|
||||
|
||||
@@ -689,6 +689,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna,
|
||||
Py_DECREF(expr_code);
|
||||
expr_code = nullptr;
|
||||
PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, nullptr);
|
||||
driver_orig->flag |= DRIVER_FLAG_PYTHON_BLOCKED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user