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-15 23:20:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-15 23:20:12 +0400
commit52a3d5c518cb969dad321d6f0486d9f33dd95791 (patch)
tree8916f211ccff06d7d1be55a1db244eae787e891e /source/gameengine/Ketsji/KX_PythonInit.cpp
parentb7e40b955fd635d703b70344dd91afc1506ecbc4 (diff)
BGE Python API
Free python modules defined within the blendfile between loading scenes since they would end up accessing old GameLogic, Rasterizer modules as well as old game engine data in the module namespace which can cause problems.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 924c5451608..eafb7fc0cb8 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -102,7 +102,7 @@ extern "C" {
#include "GPU_material.h"
static void setSandbox(TPythonSecurityLevel level);
-
+static void clearGameModules();
// 'local' copy of canvas ptr, for window height/width python scripts
static RAS_ICanvas* gp_Canvas = NULL;
@@ -1402,6 +1402,10 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev
initPyTypes();
bpy_import_main_set(maggie);
+
+ /* run this to clear game modules and user modules which
+ * may contain references to in game data */
+ clearGameModules();
PyObject* moduleobj = PyImport_AddModule("__main__");
return PyModule_GetDict(moduleobj);
@@ -1434,6 +1438,9 @@ static void clearGameModules()
clearModule(modules, "Mathutils");
clearModule(modules, "BGL");
PyErr_Clear(); // incase some of these were alredy removed.
+
+ /* clear user defined modules */
+ importClearUserModules();
}
void exitGamePythonScripting()