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:
authorCampbell Barton <ideasman42@gmail.com>2010-11-27 05:39:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-27 05:39:51 +0300
commit02cc80691d71ea305780655d3b0d4cd4530db9c7 (patch)
treef41d0aeb97e5667d4697c2a90b7fc2becc65ffa6 /source/blender/python/intern/bpy_driver.c
parent4a804855b26bd764b7752e673052c0001dce32a1 (diff)
python access to driver namespace, rather then have a textblock defined for drivers allow scripts to add functions directly.
- bpy.app.driver_namespace, read-only dictionary, edit in-place. - reset on file load and new file. - on errors the namespace used to be reset, this should not be needed. simple example. def driverFunc(val): return val * val bpy.app.driver_namespace['driverFunc'] = driverFunc ... now all drivers can access this function.
Diffstat (limited to 'source/blender/python/intern/bpy_driver.c')
-rw-r--r--source/blender/python/intern/bpy_driver.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index e5719a84fdd..6de341311be 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -40,7 +40,7 @@ PyObject *bpy_pydriver_Dict = NULL;
/* For faster execution we keep a special dictionary for pydrivers, with
* the needed modules and aliases.
*/
-static int bpy_pydriver_create_dict(void)
+int bpy_pydriver_create_dict(void)
{
PyObject *d, *mod;
@@ -103,7 +103,7 @@ static int bpy_pydriver_create_dict(void)
* reloading the Blender text module "pydrivers.py", if available, so
* updates in it reach pydriver evaluation.
*/
-void BPY_pydriver_update(void)
+void BPY_reset_driver(void)
{
PyGILState_STATE gilstate;
int use_gil= 1; // (PyThreadState_Get()==NULL);
@@ -126,12 +126,6 @@ void BPY_pydriver_update(void)
/* error return function for BPY_eval_pydriver */
static float pydriver_error(ChannelDriver *driver)
{
- if (bpy_pydriver_Dict) { /* free the global dict used by pydrivers */
- PyDict_Clear(bpy_pydriver_Dict);
- Py_DECREF(bpy_pydriver_Dict);
- bpy_pydriver_Dict = NULL;
- }
-
driver->flag |= DRIVER_FLAG_INVALID; /* py expression failed */
fprintf(stderr, "\nError in Driver: The following Python expression failed:\n\t'%s'\n\n", driver->expression);