Fix: Wrong message in driver for disabled execution
This backports the following 2 commits to 4.21a8053939be2bc41598dThese two fix an issue where the driver stated it is invalid, while in fact it couldn't execute due to python being blocked. Original report: #106372 Pull Request: https://projects.blender.org/blender/blender/pulls/126088
This commit is contained in:
committed by
Philipp Oeser
parent
9bb014dcd9
commit
53f0c2c14d
@@ -2701,7 +2701,7 @@ void BKE_fcurve_blend_read_data(BlendDataReader *reader, FCurve *fcu)
|
||||
|
||||
/* Give the driver a fresh chance - the operating environment may be different now
|
||||
* (addons, etc. may be different) so the driver namespace may be sane now #32155. */
|
||||
driver->flag &= ~DRIVER_FLAG_INVALID;
|
||||
driver->flag &= ~(DRIVER_FLAG_INVALID | DRIVER_FLAG_PYTHON_BLOCKED);
|
||||
|
||||
/* relink variables, targets and their paths */
|
||||
BLO_read_struct_list(reader, DriverVar, &driver->variables);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -570,7 +570,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;
|
||||
|
||||
@@ -527,6 +527,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna,
|
||||
|
||||
printf("skipping driver '%s', automatic scripts are disabled\n", expr);
|
||||
}
|
||||
driver_orig->flag |= DRIVER_FLAG_PYTHON_BLOCKED;
|
||||
return 0.0f;
|
||||
}
|
||||
#else
|
||||
@@ -581,6 +582,7 @@ float BPY_driver_exec(PathResolvedRNA *anim_rna,
|
||||
|
||||
/* Maybe this can be removed but for now best keep until were sure. */
|
||||
driver_orig->flag |= DRIVER_FLAG_RENAMEVAR;
|
||||
driver_orig->flag &= ~DRIVER_FLAG_PYTHON_BLOCKED;
|
||||
#ifdef USE_BYTECODE_WHITELIST
|
||||
is_recompile = true;
|
||||
#endif
|
||||
@@ -689,6 +691,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