BGE PyAPI Bug reported by Pitel on blenderartist.

importing "pygame" failed when running the BGE for the second time.

Rather then clearing modules, backup and restore them (as its doing with sys.path)

This way the BGE will never remember any modules imported during game play (which can cause bugs/crashes), but it also wont break pythons state by possibly removing modules that are being used internally.
This commit is contained in:
2009-05-26 18:06:09 +00:00
parent 74977721a4
commit 25569b0f7d
3 changed files with 38 additions and 66 deletions

View File

@@ -281,6 +281,7 @@ PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", blender_reload, METH_VARAR
* even if we remove a python module a reimport will bring it back again.
*/
#if 0 // not used anymore but may still come in handy later
#if defined(WIN32) || defined(WIN64)
#define SEPSTR "\\"
@@ -336,4 +337,4 @@ void bpy_text_clear_modules(int clear_all)
Py_DECREF(list); /* removes all references from append */
}
#endif

View File

@@ -37,7 +37,7 @@
PyObject* bpy_text_import( char *name, int *found );
PyObject* bpy_text_reimport( PyObject *module, int *found );
void bpy_text_clear_modules( int clear_all ); /* Clear user modules */
/* void bpy_text_clear_modules( int clear_all );*/ /* Clear user modules */
extern PyMethodDef bpy_import_meth[];
extern PyMethodDef bpy_reload_meth[];