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>2009-04-30 03:39:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-30 03:39:27 +0400
commit1e7df5851959db6822bdc2a71b83aa533b0ec117 (patch)
tree11eed5eee6c03d3c1dfe88c2c714ec66d1965b37 /source/gameengine/Expressions
parent537b0803798674501634c4dfbaeedb97b2ee889c (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/Expressions')
-rw-r--r--source/gameengine/Expressions/InputParser.cpp16
-rw-r--r--source/gameengine/Expressions/Value.cpp16
2 files changed, 28 insertions, 4 deletions
diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp
index d45a9375dc7..834faf70aae 100644
--- a/source/gameengine/Expressions/InputParser.cpp
+++ b/source/gameengine/Expressions/InputParser.cpp
@@ -676,11 +676,23 @@ static struct PyModuleDef Expression_module_def = {
extern "C" {
void initExpressionModule(void)
{
+ PyObject *m;
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "Expression" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
#if (PY_VERSION_HEX >= 0x03000000)
- PyModule_Create(&Expression_module_def);
+ PyModule_Create(&Expression_module_def);
#else
- Py_InitModule("Expression",CParserMethods);
+ Py_InitModule("Expression",CParserMethods);
#endif
+ }
}
}
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index fbd86cc4022..373924301ae 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -773,11 +773,23 @@ static struct PyModuleDef CValue_module_def = {
extern "C" {
void initCValue(void)
{
+ PyObject *m;
+ /* Use existing module where possible
+ * be careful not to init any runtime vars after this */
+ m = PyImport_ImportModule( "CValue" );
+ if(m) {
+ Py_DECREF(m);
+ return m;
+ }
+ else {
+ PyErr_Clear();
+
#if (PY_VERSION_HEX >= 0x03000000)
- PyModule_Create(&CValue_module_def);
+ PyModule_Create(&CValue_module_def);
#else
- Py_InitModule("CValue",CValueMethods);
+ Py_InitModule("CValue",CValueMethods);
#endif
+ }
}
}