Fix for own recent reference count error.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 15 Apr 2009 04:34:27 +0000 (04:34 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 15 Apr 2009 04:34:27 +0000 (04:34 +0000)
- The armature weakref list was  being incref'd twice then decrefed twice (incref and decref were used incorrectly), now only once. My 'fix' broke this.
- In bpy_pydriver_create_dict the 2 refs added from running PyDict_SetItemString twice were undone when clearing the dictionary (added comment)
- changed Py_XDECREF to Py_DECREF int BPY_pyconstraint_update and BPY_pyconstraint_target, Py_XDECREF checs for NULL value which would have crashed blender before it got to Py_XDECREF anyway.
- after every error is reported (PyErr_Print), remove sys.last_traceback and clear the error, I found this fixed certain crashes (usually when starting the game engine or exiting blender), so best do this all the time.

- header_text.c, CcdPhysicsEnvironment.cpp, KX_CameraActuator.cpp - remove some warnings.

source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
source/blender/python/BPY_interface.c
source/blender/python/api2_2x/Draw.c
source/blender/python/api2_2x/bpy_internal_import.c
source/blender/src/header_text.c
source/blender/src/imagepaint.c
source/gameengine/GameLogic/SCA_PythonController.cpp
source/gameengine/Ketsji/KX_CameraActuator.cpp
source/gameengine/Ketsji/KX_PolygonMaterial.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index 2065ac2ed338a7730f29ac9ce1da25ad1d1bbeef..88efd47fa66846754fdda2b10cbb8da728c243b9 100644 (file)
@@ -340,7 +340,11 @@ static void node_dynamic_pyerror_print(bNode *node)
        PyGILState_STATE gilstate = PyGILState_Ensure();
 
        fprintf(stderr, "\nError in dynamic node script \"%s\":\n", node->name);
-       if (PyErr_Occurred()) { PyErr_Print(); }
+       if (PyErr_Occurred()) {
+               PyErr_Print();
+               PyErr_Clear();
+               PySys_SetObject("last_traceback", NULL);
+       }
        else { fprintf(stderr, "Not a valid dynamic node Python script.\n"); }
 
        PyGILState_Release(gilstate);
index 7b992dff472a60021c17f19b7a378168d81ce320..c46c6c083b269d908cf6d10ce6d49222ac8b82cd 100644 (file)
@@ -97,6 +97,17 @@ PyObject *bpy_pydriver_Dict = NULL;
 PyObject *bpy_orig_syspath_List = NULL;
 
 
+static void BPY_Err_Clear(void)
+{      
+       /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+        * their user count. Not to mention holding references to wrapped data.
+        * This is especially bad when the PyObject for the wrapped data is free'd, after blender 
+        * has alredy dealocated the pointer */
+       PySys_SetObject( "last_traceback", NULL);
+       
+       PyErr_Clear();
+}
+
 /*
  * set up a weakref list for Armatures
  *    creates list in __main__ module dict 
@@ -107,30 +118,29 @@ static int setup_armature_weakrefs()
        PyObject *maindict;
        PyObject *main_module;
        PyObject *list;
-       char *list_name = ARM_WEAKREF_LIST_NAME;
+       PyObject *list_name = PyString_FromString(ARM_WEAKREF_LIST_NAME);
 
        main_module = PyImport_AddModule( "__main__");
        if(main_module){
-               PyObject *weakreflink;
                maindict= PyModule_GetDict(main_module);
 
                /* check if there is already a dict entry for the armature weakrefs,
                 * and delete if so before making another one */
-
-               weakreflink= PyDict_GetItemString(maindict,list_name);
-               if( weakreflink != NULL ) {
-                       PyDict_DelItemString(maindict,list_name);
-                       Py_XDECREF( weakreflink );
-               }
+               
+               if (PyDict_DelItem(maindict, list_name)==-1)
+                       PyErr_Clear();
                
                list= PyList_New(0);
-               if (PyDict_SetItemString(maindict, list_name, list) == -1){
-                       printf("Oops - setup_armature_weakrefs()\n");
+               if (PyDict_SetItem(maindict, list_name, list) == -1){
+                       PyErr_Print();
+                       BPY_Err_Clear();
                        Py_DECREF(list);
+                       Py_DECREF(list_name);
                        return 0;
                }
                Py_DECREF(list); /* the dict owns it now */
        }
+       Py_DECREF(list_name);
        return 1;
 }
 
@@ -532,16 +542,6 @@ static PyObject *traceback_getFilename( PyObject * tb )
        else return PyString_FromString("unknown");
 }
 
-static void BPY_Err_Clear(void)
-{      
-       /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
-        * their user count. Not to mention holding references to wrapped data.
-        * This is especially bad when the PyObject for the wrapped data is free'd, after blender 
-        * has alredy dealocated the pointer */
-       PySys_SetObject( "last_traceback", Py_None);
-       
-       PyErr_Clear();
-}
 /****************************************************************************
 * Description: Blender Python error handler. This catches the error and        
 * stores filename and line number in a global  
@@ -1137,6 +1137,7 @@ void BPY_free_finished_script( Script * script )
 
        if( PyErr_Occurred(  ) ) {      /* if script ended after filesel */
                PyErr_Print(  );        /* eventual errors are handled now */
+               BPY_Err_Clear(  );
                error_pyscript(  );
        }
 
@@ -1245,10 +1246,9 @@ static int bpy_pydriver_create_dict(void)
        if (mod) {
                PyDict_SetItemString(d, "Blender", mod);
                PyDict_SetItemString(d, "b", mod);
-               Py_DECREF(mod);
-               Py_DECREF(mod);
+               Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */
        } else {
-               PyErr_Clear();
+               BPY_Err_Clear();
        }
 
        mod = PyImport_ImportModule("math");
@@ -1258,18 +1258,18 @@ static int bpy_pydriver_create_dict(void)
                /* Only keep for backwards compat! - just import all math into root, they are standard */
                PyDict_SetItemString(d, "math", mod);
                PyDict_SetItemString(d, "m", mod);
-               Py_DECREF(mod);
-               Py_DECREF(mod);
-       } 
+               Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */
+       } else {
+               BPY_Err_Clear();
+       }
 
        mod = PyImport_ImportModule("Blender.Noise");
        if (mod) {
                PyDict_SetItemString(d, "noise", mod);
                PyDict_SetItemString(d, "n", mod);
-               Py_DECREF(mod);
-               Py_DECREF(mod);
+               Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */
        } else {
-               PyErr_Clear();
+               BPY_Err_Clear();
        }
 
        /* If there's a Blender text called pydrivers.py, import it.
@@ -1279,10 +1279,9 @@ static int bpy_pydriver_create_dict(void)
                if (mod) {
                        PyDict_SetItemString(d, "pydrivers", mod);
                        PyDict_SetItemString(d, "p", mod);
-                       Py_DECREF(mod);
-                       Py_DECREF(mod);
+                       Py_DECREF(mod); /* 2 refs above are cleared with the dict, only decref the ref from PyImport_ImportModule */
                } else {
-                       PyErr_Clear();
+                       BPY_Err_Clear();
                }
        }
        /* short aliases for some Get() functions: */
@@ -1297,7 +1296,7 @@ static int bpy_pydriver_create_dict(void)
                        Py_DECREF(fcn);
                }
        } else {
-               PyErr_Clear();
+               BPY_Err_Clear();
        }
        
        /* TODO - change these */
@@ -1311,7 +1310,7 @@ static int bpy_pydriver_create_dict(void)
                        Py_DECREF(fcn);
                }
        } else {
-               PyErr_Clear();
+               BPY_Err_Clear();
        }
 
        /* ma(matname) == Blender.Material.Get(matname) */
@@ -1324,7 +1323,7 @@ static int bpy_pydriver_create_dict(void)
                        Py_DECREF(fcn);
                }
        } else {
-               PyErr_Clear();
+               BPY_Err_Clear();
        }
 
        return 0;
@@ -1350,6 +1349,7 @@ static float pydriver_error(IpoDriver *driver) {
                fprintf(stderr, "\nError in Ipo Driver: No Object\nThis is the failed Python expression:\n'%s'\n\n", driver->name);
        
        PyErr_Print();
+       BPY_Err_Clear();
 
        return 0.0f;
 }
@@ -1445,7 +1445,7 @@ void BPY_pyconstraint_update(Object *owner, bConstraint *con)
                        return;
                }
                
-               Py_XDECREF(retval);
+               Py_DECREF(retval);
                retval = NULL;
                
                /* try to find NUM_TARGETS */
@@ -1578,9 +1578,9 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
                con->flag |= PYCON_SCRIPTERROR;
                
                /* free temp objects */
-               Py_XDECREF(idprop);
-               Py_XDECREF(srcmat);
-               Py_XDECREF(tarmats);
+               Py_DECREF(idprop);
+               Py_DECREF(srcmat);
+               Py_DECREF(tarmats);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1589,7 +1589,7 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
                return;
        }
 
-       if (retval) {Py_XDECREF( retval );}
+       Py_DECREF( retval );
        retval = NULL;
        
        gval = PyDict_GetItemString(globals, "doConstraint");
@@ -1597,9 +1597,9 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
                printf("ERROR: no doConstraint function in constraint!\n");
                
                /* free temp objects */
-               Py_XDECREF(idprop);
-               Py_XDECREF(srcmat);
-               Py_XDECREF(tarmats);
+               Py_DECREF(idprop);
+               Py_DECREF(srcmat);
+               Py_DECREF(tarmats);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1612,15 +1612,15 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
        if (PyFunction_Check(gval)) {
                pyargs = Py_BuildValue("OOO", srcmat, tarmats, idprop);
                retval = PyObject_CallObject(gval, pyargs);
-               Py_XDECREF(pyargs);
+               Py_DECREF(pyargs);
        } 
        else {
                printf("ERROR: doConstraint is supposed to be a function!\n");
                con->flag |= PYCON_SCRIPTERROR;
                
-               Py_XDECREF(idprop);
-               Py_XDECREF(srcmat);
-               Py_XDECREF(tarmats);
+               Py_DECREF(idprop);
+               Py_DECREF(srcmat);
+               Py_DECREF(tarmats);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1634,9 +1634,9 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
                con->flag |= PYCON_SCRIPTERROR;
                
                /* free temp objects */
-               Py_XDECREF(idprop);
-               Py_XDECREF(srcmat);
-               Py_XDECREF(tarmats);
+               Py_DECREF(idprop);
+               Py_DECREF(srcmat);
+               Py_DECREF(tarmats);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1650,10 +1650,10 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
                printf("Error in PyConstraint - doConstraint: Function not returning a matrix!\n");
                con->flag |= PYCON_SCRIPTERROR;
                
-               Py_XDECREF(idprop);
-               Py_XDECREF(srcmat);
-               Py_XDECREF(tarmats);
-               Py_XDECREF(retval);
+               Py_DECREF(idprop);
+               Py_DECREF(srcmat);
+               Py_DECREF(tarmats);
+               Py_DECREF(retval);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1667,10 +1667,10 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
                printf("Error in PyConstraint - doConstraint: Matrix returned is the wrong size!\n");
                con->flag |= PYCON_SCRIPTERROR;
                
-               Py_XDECREF(idprop);
-               Py_XDECREF(srcmat);
-               Py_XDECREF(tarmats);
-               Py_XDECREF(retval);
+               Py_DECREF(idprop);
+               Py_DECREF(srcmat);
+               Py_DECREF(tarmats);
+               Py_DECREF(retval);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1687,10 +1687,10 @@ void BPY_pyconstraint_eval(bPythonConstraint *con, bConstraintOb *cob, ListBase
        }
        
        /* free temp objects */
-       Py_XDECREF(idprop);
-       Py_XDECREF(srcmat);
-       Py_XDECREF(tarmats);
-       Py_XDECREF(retval);
+       Py_DECREF(idprop);
+       Py_DECREF(srcmat);
+       Py_DECREF(tarmats);
+       Py_DECREF(retval);
        
        /* clear globals */
        ReleaseGlobalDictionary(globals);
@@ -1745,10 +1745,10 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
                con->flag |= PYCON_SCRIPTERROR;
                
                /* free temp objects */
-               Py_XDECREF(tar);
-               Py_XDECREF(subtar);
-               Py_XDECREF(idprop);
-               Py_XDECREF(tarmat);
+               Py_DECREF(tar);
+               Py_DECREF(subtar);
+               Py_DECREF(idprop);
+               Py_DECREF(tarmat);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1757,17 +1757,17 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
                return;
        }
 
-       Py_XDECREF(retval);
+       Py_DECREF(retval);
        retval = NULL;
        
        /* try to find doTarget function to set the target matrix */
        gval = PyDict_GetItemString(globals, "doTarget");
        if (!gval) {
                /* free temp objects */
-               Py_XDECREF(tar);
-               Py_XDECREF(subtar);
-               Py_XDECREF(idprop);
-               Py_XDECREF(tarmat);
+               Py_DECREF(tar);
+               Py_DECREF(subtar);
+               Py_DECREF(idprop);
+               Py_DECREF(tarmat);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1780,16 +1780,16 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
        if (PyFunction_Check(gval)) {
                pyargs = Py_BuildValue("OOOO", tar, subtar, tarmat, idprop);
                retval = PyObject_CallObject(gval, pyargs);
-               Py_XDECREF(pyargs);
+               Py_DECREF(pyargs);
        } 
        else {
                printf("ERROR: doTarget is supposed to be a function!\n");
                con->flag |= PYCON_SCRIPTERROR;
                
-               Py_XDECREF(tar);
-               Py_XDECREF(subtar);
-               Py_XDECREF(idprop);
-               Py_XDECREF(tarmat);
+               Py_DECREF(tar);
+               Py_DECREF(subtar);
+               Py_DECREF(idprop);
+               Py_DECREF(tarmat);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1804,10 +1804,10 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
                
                
                /* free temp objects */
-               Py_XDECREF(tar);
-               Py_XDECREF(subtar);
-               Py_XDECREF(idprop);
-               Py_XDECREF(tarmat);
+               Py_DECREF(tar);
+               Py_DECREF(subtar);
+               Py_DECREF(idprop);
+               Py_DECREF(tarmat);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1819,11 +1819,11 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
        if (!PyObject_TypeCheck(retval, &matrix_Type)) {
                con->flag |= PYCON_SCRIPTERROR;
                
-               Py_XDECREF(tar);
-               Py_XDECREF(subtar);
-               Py_XDECREF(idprop);
-               Py_XDECREF(tarmat);
-               Py_XDECREF(retval);
+               Py_DECREF(tar);
+               Py_DECREF(subtar);
+               Py_DECREF(idprop);
+               Py_DECREF(tarmat);
+               Py_DECREF(retval);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1837,11 +1837,11 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
                printf("Error in PyConstraint - doTarget: Matrix returned is the wrong size!\n");
                con->flag |= PYCON_SCRIPTERROR;
                
-               Py_XDECREF(tar);
-               Py_XDECREF(subtar);
-               Py_XDECREF(idprop);
-               Py_XDECREF(tarmat);
-               Py_XDECREF(retval);
+               Py_DECREF(tar);
+               Py_DECREF(subtar);
+               Py_DECREF(idprop);
+               Py_DECREF(tarmat);
+               Py_DECREF(retval);
                
                ReleaseGlobalDictionary(globals);
 
@@ -1858,11 +1858,11 @@ void BPY_pyconstraint_target(bPythonConstraint *con, bConstraintTarget *ct)
        }
        
        /* free temp objects */
-       Py_XDECREF(tar);
-       Py_XDECREF(subtar);
-       Py_XDECREF(idprop);
-       Py_XDECREF(tarmat);
-       Py_XDECREF(retval);
+       Py_DECREF(tar);
+       Py_DECREF(subtar);
+       Py_DECREF(idprop);
+       Py_DECREF(tarmat);
+       Py_DECREF(retval);
        
        /* clear globals */
        ReleaseGlobalDictionary(globals);
@@ -1897,7 +1897,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2)
                con->flag |= PYCON_SCRIPTERROR;
                
                /* free temp objects */
-               Py_XDECREF(idprop);
+               Py_DECREF(idprop);
                
                PyGILState_Release(gilstate);
                
@@ -1913,7 +1913,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2)
                
                /* free temp objects */
                ReleaseGlobalDictionary( globals );
-               Py_XDECREF(idprop);
+               Py_DECREF(idprop);
 
                PyGILState_Release(gilstate);
 
@@ -1928,7 +1928,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2)
                printf("ERROR: getSettings is supposed to be a function!\n");
                ReleaseGlobalDictionary( globals );
                
-               Py_XDECREF(idprop);
+               Py_DECREF(idprop);
                
                PyGILState_Release(gilstate);
                
@@ -1941,7 +1941,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2)
                
                /* free temp objects */
                ReleaseGlobalDictionary(globals);
-               Py_XDECREF(idprop);
+               Py_DECREF(idprop);
                
                PyGILState_Release(gilstate);
                
@@ -1952,7 +1952,7 @@ void BPY_pyconstraint_settings(void *arg1, void *arg2)
                ReleaseGlobalDictionary(globals);
                
                /* free temp objects */
-               Py_XDECREF(idprop);
+               Py_DECREF(idprop);
                Py_DECREF(retval);
                
                PyGILState_Release(gilstate);
@@ -2107,6 +2107,7 @@ static int bpy_button_eval_error(char *expr) {
        fprintf(stderr, "\nError in button evaluation:\nThis is the failed Python expression:\n'%s'\n\n", expr);
 
        PyErr_Print();
+       BPY_Err_Clear();
 
        return -1;
 }
index 2af2261808b34409177a56368e8e3def32261e80..57b3869d775c63e411f9ef46574c1ffc8c3afec4 100644 (file)
@@ -614,6 +614,9 @@ static void exit_pydraw( SpaceScript * sc, short err )
 
        if( err ) {
                PyErr_Print(  );
+               PyErr_Clear(  );
+               PySys_SetObject("last_traceback", NULL);
+               
                script->flags = 0;      /* mark script struct for deletion */
                SCRIPT_SET_NULL(script);
                script->scriptname[0] = '\0';
@@ -838,6 +841,8 @@ static void exec_but_callback(void *pyobj, void *data)
        if (!result) {
                Py_DECREF(pyvalue);
                PyErr_Print(  );
+               PyErr_Clear(  );
+               PySys_SetObject("last_traceback", NULL);
                error_pyscript(  );
        }
        Py_XDECREF( result );
@@ -1129,6 +1134,8 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
        
        if (!result) {
                PyErr_Print(  );
+               PyErr_Clear(  );
+               PySys_SetObject("last_traceback", NULL);
                error_pyscript(  );
        } else {
                /* copied from do_clever_numbuts in toolbox.c */
index d022fddeb5742bf90ff5106f027d97c78015d1b1..9d2d15e0991f6c8e7a4a20b709490b753704dafc 100644 (file)
@@ -84,6 +84,8 @@ PyObject *importText( char *name )
 
                if( PyErr_Occurred(  ) ) {
                        PyErr_Print(  );
+                       PyErr_Clear(  );
+                       PySys_SetObject("last_traceback", NULL);
                        free_compiled_text( text );
                        return NULL;
                }
@@ -138,6 +140,8 @@ PyObject *reimportText( PyObject *module )
        /* if compile failed.... return this error */
        if( PyErr_Occurred(  ) ) {
                PyErr_Print(  );
+               PyErr_Clear(  );
+               PySys_SetObject("last_traceback", NULL);
                free_compiled_text( text );
                return NULL;
        }
@@ -182,7 +186,7 @@ static PyObject *blender_import( PyObject * self, PyObject * args,  PyObject * k
                Py_XDECREF( exception );
                Py_XDECREF( err );
                Py_XDECREF( tb );
-               printf( "imported from text buffer...\n" );
+               /* printf( "imported from text buffer...\n" ); */
        } else {
                PyErr_Restore( exception, err, tb );
        }
index 050ff192df60714c69ee9b0abeed89fa98f54e62..850b7d6cab11378ab09cb9b0ee03085e6eb17e97 100644 (file)
@@ -74,6 +74,7 @@
 #include "BIF_toolbox.h"
 
 #include "BKE_global.h"
+#include "BKE_scene.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
 #include "BKE_sca.h"
index 09666f4819d3e3c5b19000643a116acba9c19c18..ede6679b9f589a670eb3a8cd75a845b5e616da22 100644 (file)
@@ -1921,7 +1921,7 @@ static void rect_to_uvspace_persp(
 }
 
 /* This works as we need it to but we can save a few steps and not use it */
-
+#if 0
 static float angle_2d_clockwise(const float p1[2], const float p2[2], const float p3[2])
 {
        float v1[2], v2[2];
@@ -1931,6 +1931,7 @@ static float angle_2d_clockwise(const float p1[2], const float p2[2], const floa
        
        return -atan2(v1[0]*v2[1] - v1[1]*v2[0], v1[0]*v2[0]+v1[1]*v2[1]);
 }
+#endif
 
 #define ISECT_1 (1)
 #define ISECT_2 (1<<1)
index 0e6b9d1e8f18aedb1aa58b6bf4084063881d83fd..1c5b597f93781286aa2bcb269c772c08c651cc1a 100644 (file)
@@ -300,7 +300,7 @@ bool SCA_PythonController::Compile()
                 * their user count. Not to mention holding references to wrapped data.
                 * This is especially bad when the PyObject for the wrapped data is free'd, after blender 
                 * has alredy dealocated the pointer */
-               PySys_SetObject( (char *)"last_traceback", Py_None);
+               PySys_SetObject( (char *)"last_traceback", NULL);
                PyErr_Clear(); /* just to be sure */
                
                return false;
@@ -358,7 +358,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
                 * their user count. Not to mention holding references to wrapped data.
                 * This is especially bad when the PyObject for the wrapped data is free'd, after blender 
                 * has alredy dealocated the pointer */
-               PySys_SetObject( (char *)"last_traceback", Py_None);
+               PySys_SetObject( (char *)"last_traceback", NULL);
                PyErr_Clear(); /* just to be sure */
                
                //PyRun_SimpleString(m_scriptText.Ptr());
index 0118e4907738376c0fac6575f80c29dcecf133d7..329d31cfa259c629dbaa6407ffb33db8902ac1bd 100644 (file)
@@ -611,7 +611,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF
        if (self->m_ob)
                self->m_ob->UnregisterActuator(self);   
 
-       if (self->m_ob = (SCA_IObject*)gameobj)
+       if ((self->m_ob = (SCA_IObject*)gameobj))
                self->m_ob->RegisterActuator(self);
        
        return 0;
index 56a1daa754406ee2d03fc3a139f54178c620e9c1..056442f77d9021c89162f4f52e77b7c7b9418ec5 100644 (file)
@@ -109,6 +109,8 @@ bool KX_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingI
                else
                {
                        PyErr_Print();
+                       PyErr_Clear();
+                       PySys_SetObject( (char *)"last_traceback", NULL);
                }
        }
        else
index 858416bae6a88de39ffbb8c4792cb2fcaf0c0bb4..3e1e0294321ec43cdef7db2ce6a7ac92f4468036 100644 (file)
@@ -1346,7 +1346,7 @@ struct OcclusionBuffer
        static int      clip(const btVector4* pi,btVector4* po)
        {
                btScalar        s[2*NP];
-               btVector4       pn[2*NP], *p;
+               btVector4       pn[2*NP];
                int                     i, j, m, n, ni;
                // deal with near clipping
                for(i=0, m=0;i<NP;++i)