Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2014-03-08 03:31:58 +0400
committerJoshua Leung <aligorith@gmail.com>2014-03-08 03:32:56 +0400
commit9e881d0d5b1d4de8189036e2b14344eb2c1afde6 (patch)
tree408d9ea736a6bf518c9b9caca90379bd0f0bfac1 /source/blender/editors/space_graph/graph_buttons.c
parent36279afbd356364b4b6e059d675ba0515b6b7a44 (diff)
Drivers UI: Add explicit warnings about use of bpy.data and bpy.context in expressions
In order to combat the problem of users frequently trying to use inlined bpy.data/bpy.context paths for data access in their driver expressions and then finding/complaining that these don't update correctly, the UI now flags these as the error conditions that they are (with suggestions on how to fix this). Also tweaked the "Add Variable" button to have more descriptive text about what exactly variables are and why to use these, along with some other visual tweaks (icons!).
Diffstat (limited to 'source/blender/editors/space_graph/graph_buttons.c')
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index a01f4bcaaf1..42aa9935251 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -600,12 +600,16 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* general actions - management */
col = uiLayoutColumn(pa->layout, FALSE);
block = uiLayoutGetBlock(col);
- but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22,
- NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
+ but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
+ 0, 0, 10 * UI_UNIT_X, 22,
+ NULL, 0.0, 0.0, 0, 0,
+ TIP_("Force updates of dependencies"));
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
- but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18,
- NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
+ but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"),
+ 0, 0, 10 * UI_UNIT_X, 18,
+ NULL, 0.0, 0.0, 0, 0,
+ TIP_("Remove this driver"));
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
/* driver-level settings - type, expressions, and errors */
@@ -617,15 +621,31 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
if (driver->type == DRIVER_TYPE_PYTHON) {
+ bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
+ bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL);
+
/* expression */
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
/* errors? */
if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
- uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_ERROR);
+ uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
}
else if (driver->flag & DRIVER_FLAG_INVALID) {
- uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_ERROR);
+ uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL);
+ }
+
+ /* Explicit bpy-references are evil. Warn about these to prevent errors */
+ /* TODO: put these in a box? */
+ if (bpy_data_expr_error || bpy_ctx_expr_error) {
+ uiItemL(col, IFACE_("WARNING: Driver expression may not work correctly"), ICON_HELP);
+
+ if (bpy_data_expr_error) {
+ uiItemL(col, IFACE_("TIP: Use variables instead of bpy.data paths (see below)"), ICON_ERROR);
+ }
+ if (bpy_ctx_expr_error) {
+ uiItemL(col, IFACE_("TIP: bpy.context is not safe for renderfarm usage"), ICON_ERROR);
+ }
}
}
else {
@@ -652,8 +672,10 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
/* add driver variables */
col = uiLayoutColumn(pa->layout, FALSE);
block = uiLayoutGetBlock(col);
- but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
- NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
+ but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"),
+ 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
+ NULL, 0.0, 0.0, 0, 0,
+ TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly"));
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
/* loop over targets, drawing them */