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-05-22 13:48:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-22 13:48:05 +0400
commit66ed4325f488d408f4a9179decced37bd1d816ad (patch)
treec87d7e768382f7aae61cabe08bb71b1752a49ce4
parentec60c74f081b006a6e8aebefe930a37aac95b865 (diff)
the debug option for BGE scripts only reloaded modules but not packages submodules.
Now reload all the submodules too. It was also hiding the error message if there was a syntax error which wasnt so helpful.
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index d58259457e6..8140dbd53db 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -324,10 +324,7 @@ bool SCA_PythonController::Import()
}
PyObject *mod = PyImport_ImportModule((char *)py_function_path[0].Ptr());
- if(mod && m_debug) {
- Py_DECREF(mod); /* getting a new one so dont hold a ref to the old one */
- mod= PyImport_ReloadModule(mod);
- }
+ /* Dont reload yet, do this within the loop so packages reload too */
if(mod==NULL) {
ErrorPrint("Python module not found");
@@ -339,18 +336,29 @@ bool SCA_PythonController::Import()
PyObject *base= mod;
for(unsigned int i=1; i < py_function_path.size(); i++) {
+ if(m_debug) {
+ Py_DECREF(base); /* getting a new one so dont hold a ref to the old one */
+ base= PyImport_ReloadModule(base);
+ if (base==NULL) {
+ m_function= NULL;
+ break;
+ }
+ }
+
m_function = PyObject_GetAttrString(base, py_function_path[i].Ptr());
Py_DECREF(base);
base = m_function; /* for the next loop if there is on */
if(m_function==NULL) {
- PyErr_Clear(); /* print our own error below */
break;
}
}
if(m_function==NULL) {
- printf("Python module error \"%s\":\n \"%s\" module found but function missing\n", GetName().Ptr(), m_scriptText.Ptr());
+ if(PyErr_Occurred())
+ ErrorPrint("Python controller found the module but could not access the function");
+ else
+ printf("Python module error \"%s\":\n \"%s\" module found but function missing\n", GetName().Ptr(), m_scriptText.Ptr());
return false;
}