Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Sun, 17 Jun 2018 18:37:10 +0000 (20:37 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 17 Jun 2018 18:37:10 +0000 (20:37 +0200)
1  2 
CMakeLists.txt
source/blender/editors/space_graph/graph_buttons.c
source/blender/python/intern/bpy_driver.c

diff --cc CMakeLists.txt
Simple merge
@@@ -787,21 -778,11 +787,21 @@@ static void graph_draw_driver_settings_
                bool bpy_ctx_expr_error  = (strstr(driver->expression, "bpy.context.") != NULL);
  
                /* expression */
 -              uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
 +              /* TODO: "Show syntax hints" button */
 +              col = uiLayoutColumn(layout, true);
 +              block = uiLayoutGetBlock(col);
 +
 +              uiItemL(col, IFACE_("Expression:"), ICON_NONE);
 +              uiItemR(col, &driver_ptr, "expression", 0, "", ICON_NONE);
 +              uiItemR(col, &driver_ptr, "use_self", 0, NULL, ICON_NONE);
  
                /* errors? */
 +              col = uiLayoutColumn(layout, true);
 +              block = uiLayoutGetBlock(col);
 +
                if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
-                       uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
 +                      /* TODO: Add button to enable? */
+                       uiItemL(col, IFACE_("WARNING: Python expressions limited for security"), ICON_ERROR);
                }
                else if (driver->flag & DRIVER_FLAG_INVALID) {
                        uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL);
@@@ -262,33 -447,36 +453,36 @@@ float BPY_driver_exec(struct PathResolv
                bpy_pydriver_namespace_clear_self();
        }
  
 -      if (driver->expr_comp == NULL)
 -              driver->flag |= DRIVER_FLAG_RECOMPILE;
 +      if (driver_orig->expr_comp == NULL)
 +              driver_orig->flag |= DRIVER_FLAG_RECOMPILE;
  
        /* compile the expression first if it hasn't been compiled or needs to be rebuilt */
 -      if (driver->flag & DRIVER_FLAG_RECOMPILE) {
 -              Py_XDECREF(driver->expr_comp);
 -              driver->expr_comp = PyTuple_New(2);
 +      if (driver_orig->flag & DRIVER_FLAG_RECOMPILE) {
 +              Py_XDECREF(driver_orig->expr_comp);
 +              driver_orig->expr_comp = PyTuple_New(2);
  
                expr_code = Py_CompileString(expr, "<bpy driver>", Py_eval_input);
 -              PyTuple_SET_ITEM(((PyObject *)driver->expr_comp), 0, expr_code);
 +              PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, expr_code);
  
 -              driver->flag &= ~DRIVER_FLAG_RECOMPILE;
 -              driver->flag |= DRIVER_FLAG_RENAMEVAR; /* maybe this can be removed but for now best keep until were sure */
 +              driver_orig->flag &= ~DRIVER_FLAG_RECOMPILE;
 +              driver_orig->flag |= DRIVER_FLAG_RENAMEVAR; /* maybe this can be removed but for now best keep until were sure */
+ #ifdef USE_BYTECODE_WHITELIST
+               is_recompile = true;
+ #endif
        }
        else {
 -              expr_code = PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 0);
 +              expr_code = PyTuple_GET_ITEM(((PyObject *)driver_orig->expr_comp), 0);
        }
  
 -      if (driver->flag & DRIVER_FLAG_RENAMEVAR) {
 +      if (driver_orig->flag & DRIVER_FLAG_RENAMEVAR) {
                /* may not be set */
 -              expr_vars = PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 1);
 +              expr_vars = PyTuple_GET_ITEM(((PyObject *)driver_orig->expr_comp), 1);
                Py_XDECREF(expr_vars);
  
 -              expr_vars = PyTuple_New(BLI_listbase_count(&driver->variables));
 -              PyTuple_SET_ITEM(((PyObject *)driver->expr_comp), 1, expr_vars);
 +              expr_vars = PyTuple_New(BLI_listbase_count(&driver_orig->variables));
 +              PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 1, expr_vars);
  
 -              for (dvar = driver->variables.first, i = 0; dvar; dvar = dvar->next) {
 +              for (dvar = driver_orig->variables.first, i = 0; dvar; dvar = dvar->next) {
                        PyTuple_SET_ITEM(expr_vars, i++, PyUnicode_FromString(dvar->name));
                }