diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-04-30 03:39:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-04-30 03:39:27 +0400 |
commit | 1e7df5851959db6822bdc2a71b83aa533b0ec117 (patch) | |
tree | 11eed5eee6c03d3c1dfe88c2c714ec66d1965b37 /source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | |
parent | 537b0803798674501634c4dfbaeedb97b2ee889c (diff) |
python modules in the game engine could point to builtin modules like GameLogic that was cleared.
I added module clearing before there was checks for invalid python objects, so now its not needed for BGE Builtin types at least.
also made the builtin modules get re-used if they already exist and clear all user modules when the game engine finishes so with Module-Py-Controllers the referenced modules are at least up to date when pressing Pkey.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PyConstraintBinding.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index e801e9c5858..0f21b24489d 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -586,13 +586,24 @@ PyObject* initPythonConstraintBinding() PyObject* m; PyObject* d; + /* Use existing module where possible + * be careful not to init any runtime vars after this */ + m = PyImport_ImportModule( "PhysicsConstraints" ); + if(m) { + Py_DECREF(m); + return m; + } + else { + PyErr_Clear(); + #if (PY_VERSION_HEX >= 0x03000000) - m = PyModule_Create(&PhysicsConstraints_module_def); + m = PyModule_Create(&PhysicsConstraints_module_def); #else - m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods, + m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods, PhysicsConstraints_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); #endif + } // Add some symbolic constants to the module d = PyModule_GetDict(m); |