Fix for own recent reference count error.

- 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.
This commit is contained in:
2009-04-15 04:34:27 +00:00
parent 4fe917ba26
commit efb7dd86ff
10 changed files with 127 additions and 107 deletions

View 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 */

View 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 );
}