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/VideoTexture/blendVideoTex.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/VideoTexture/blendVideoTex.cpp')
-rw-r--r-- | source/gameengine/VideoTexture/blendVideoTex.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 8b2a9dc2a5d..239f43763b8 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -192,13 +192,24 @@ PyObject* initVideoTexture(void) if (PyType_Ready(&TextureType) < 0) return NULL; + /* Use existing module where possible + * be careful not to init any runtime vars after this */ + m = PyImport_ImportModule( "VideoTexture" ); + if(m) { + Py_DECREF(m); + return m; + } + else { + PyErr_Clear(); + #if (PY_VERSION_HEX >= 0x03000000) - m = PyModule_Create(&VideoTexture_module_def); + m = PyModule_Create(&VideoTexture_module_def); #else - m = Py_InitModule4("VideoTexture", moduleMethods, - "Module that allows to play video files on textures in GameBlender.", - (PyObject*)NULL,PYTHON_API_VERSION); + m = Py_InitModule4("VideoTexture", moduleMethods, + "Module that allows to play video files on textures in GameBlender.", + (PyObject*)NULL,PYTHON_API_VERSION); #endif + } if (m == NULL) return NULL; @@ -209,9 +220,10 @@ PyObject* initVideoTexture(void) Py_INCREF(&TextureType); PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType); - + // init last error description Exception::m_lastError[0] = '\0'; + return m; } |