Small update for pydrivers: force reloading the pydrivers.py Blender

text module when user edits the input text box of any pydriver
(Transform Properties panel, Ipo window).

It's enough to click in and out of a single pydriver's text input box
for the module reloading and also re-evaluation of all pydrivers
available. Maybe this "refreshing" should also be available from a
menu, let's see.

Note for Python fans:

Definitions and redefinitions in a reloaded module are properly handled
in Python, but previously defined data in the module doesn't disappear.
So if you define a function "f" inside a module, import it, then change
the function's name to "g" and reload the module, both "f" and "g" will
be available. This is considered a feature, check reload's documentation:
http://docs.python.org/lib/built-in-funcs.html#l2h-59
This commit is contained in:
2006-04-30 22:10:39 +00:00
parent 89dab4397d
commit 066a2b2ed2
5 changed files with 25 additions and 4 deletions

View File

@@ -1021,6 +1021,7 @@ static float pydriver_error(IpoDriver *driver) {
bpy_pydriver_freeList();
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;
}
@@ -1034,6 +1035,21 @@ static float pydriver_error(IpoDriver *driver) {
return 0.0f;
}
/* Update function, it gets rid of pydrivers global dictionary, forcing
* BPY_pydriver_eval to recreate it. This function is used to force
* reloading the Blender text module "pydrivers.py", if available, so
* updates in it reach pydriver evaluation. */
void BPY_pydriver_update(void)
{
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;
}
return;
}
/* for depsgraph.c, runs py expr once to collect all refs. made
* to objects (self refs. to the object that owns the py driver
* are not allowed). */