Revision: 20339
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20339
Author:   campbellbarton
Date:     2009-05-22 11:48:05 +0200 (Fri, 22 May 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp

Modified: trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp  
2009-05-22 09:36:31 UTC (rev 20338)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp  
2009-05-22 09:48:05 UTC (rev 20339)
@@ -324,10 +324,7 @@
        }
        
        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 @@
        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;
        }
        


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to