diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-07 01:42:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-07 01:42:13 +0300 |
commit | d3a718dc2f556fd8a0dbf6e89e5317d7e85a44f2 (patch) | |
tree | 2d209e0604f766caa9e74db4d45d041604a1f353 /source/blender/python/intern | |
parent | e49e9289f088022e3dc0b23edd1d2a8bcec70dab (diff) |
fix for own but in recent driver optimization [#20580] Driver Crasher rev [25763]
recalculate names when needed
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_driver.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 6f2f7a6f3b3..f80d79d9a2a 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -177,14 +177,29 @@ float BPY_pydriver_eval (ChannelDriver *driver) } } + if(driver->expr_comp==NULL) + driver->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) || (driver->expr_comp==NULL)) { + if(driver->flag & DRIVER_FLAG_RECOMPILE) { Py_XDECREF(driver->expr_comp); driver->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); + driver->flag &= ~DRIVER_FLAG_RECOMPILE; + driver->flag |= DRIVER_FLAG_RENAMEVAR; /* maybe this can be removed but for now best keep until were sure */ + } + else { + expr_code= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 0); + } + + if(driver->flag & DRIVER_FLAG_RENAMEVAR) { + /* may not be set */ + expr_vars= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 1); + Py_XDECREF(expr_vars); + /* intern the arg names so creating the namespace for every run is faster */ expr_vars= PyTuple_New(BLI_countlist(&driver->variables)); PyTuple_SET_ITEM(((PyObject *)driver->expr_comp), 1, expr_vars); @@ -192,11 +207,8 @@ float BPY_pydriver_eval (ChannelDriver *driver) for (dvar= driver->variables.first, i=0; dvar; dvar= dvar->next) { PyTuple_SET_ITEM(expr_vars, i++, PyUnicode_InternFromString(dvar->name)); } - - driver->flag &= ~DRIVER_FLAG_RECOMPILE; } else { - expr_code= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 0); expr_vars= PyTuple_GET_ITEM(((PyObject *)driver->expr_comp), 1); } |