fix for [#8559] Python script that uses FIleSelector and has an error in it segfaults Blender
This commit is contained in:
@@ -128,7 +128,9 @@ extern "C" {
|
||||
void BPY_clear_script( struct Script *script );
|
||||
void BPY_free_finished_script( struct Script *script );
|
||||
void BPY_scripts_clear_pyobjects( void );
|
||||
|
||||
|
||||
void error_pyscript( void );
|
||||
|
||||
/* void BPY_Err_Handle(struct Text *text); */
|
||||
/* void BPY_clear_bad_scriptlink(struct ID *id, struct Text *byebye); */
|
||||
/* void BPY_clear_bad_scriptlist(struct ListBase *, struct Text *byebye); */
|
||||
|
||||
@@ -284,7 +284,6 @@ void BPY_end_python( void )
|
||||
* Python is finalized and G.main is freed in exit_usiblender() */
|
||||
for (script = G.main->script.first; script; script = next_script) {
|
||||
next_script = script->id.next;
|
||||
BPY_clear_script(script);
|
||||
free_libblock( &G.main->script, script );
|
||||
}
|
||||
|
||||
@@ -693,8 +692,7 @@ int BPY_txt_do_python_Text( struct Text *text )
|
||||
BPY_Err_Handle( textname );
|
||||
ReleaseGlobalDictionary( py_dict );
|
||||
script->py_globaldict = NULL;
|
||||
if( G.main->script.first )
|
||||
free_libblock( &G.main->script, script );
|
||||
free_libblock( &G.main->script, script );
|
||||
PyGILState_Release(gilstate);
|
||||
return 0;
|
||||
} else {
|
||||
@@ -817,8 +815,7 @@ int BPY_run_script(Script *script)
|
||||
fp = fopen( script->scriptname, "rb" );
|
||||
if( !fp ) {
|
||||
printf( "Error loading script: couldn't open file %s\n", script->scriptname );
|
||||
if( G.main->script.first )
|
||||
free_libblock( &G.main->script, script );
|
||||
free_libblock( &G.main->script, script );
|
||||
PyGILState_Release(gilstate);
|
||||
return 0;
|
||||
}
|
||||
@@ -844,8 +841,7 @@ int BPY_run_script(Script *script)
|
||||
|
||||
if( !setup_armature_weakrefs()){
|
||||
printf("Oops - weakref dict\n");
|
||||
if( G.main->script.first )
|
||||
free_libblock( &G.main->script, script );
|
||||
free_libblock( &G.main->script, script );
|
||||
ReleaseGlobalDictionary( py_dict );
|
||||
MEM_freeN( buffer );
|
||||
PyGILState_Release(gilstate);
|
||||
@@ -912,9 +908,8 @@ int BPY_run_script(Script *script)
|
||||
BPY_Err_Handle( script->id.name + 2 );
|
||||
ReleaseGlobalDictionary( py_dict );
|
||||
script->py_globaldict = NULL;
|
||||
if( G.main->script.first )
|
||||
free_libblock( &G.main->script, script );
|
||||
error( "Python script error: check console" );
|
||||
free_libblock( &G.main->script, script );
|
||||
error_pyscript( );
|
||||
|
||||
PyGILState_Release(gilstate);
|
||||
return 0;
|
||||
@@ -1112,7 +1107,7 @@ void BPY_free_finished_script( Script * script )
|
||||
|
||||
if( PyErr_Occurred( ) ) { /* if script ended after filesel */
|
||||
PyErr_Print( ); /* eventual errors are handled now */
|
||||
error( "Python script error: check console" );
|
||||
error_pyscript( );
|
||||
}
|
||||
|
||||
PyGILState_Release(gilstate);
|
||||
@@ -1148,6 +1143,7 @@ static void unlink_script( Script * script )
|
||||
}
|
||||
}
|
||||
|
||||
/* This is called from free_libblock( &G.main->script, script ); */
|
||||
void BPY_clear_script( Script * script )
|
||||
{
|
||||
PyObject *dict;
|
||||
@@ -2963,3 +2959,7 @@ void BPY_scripts_clear_pyobjects( void )
|
||||
SCRIPT_SET_NULL(script)
|
||||
}
|
||||
}
|
||||
void error_pyscript( void )
|
||||
{
|
||||
error("Python script error: check console");
|
||||
}
|
||||
|
||||
@@ -617,7 +617,8 @@ static void exit_pydraw( SpaceScript * sc, short err )
|
||||
if( err ) {
|
||||
PyErr_Print( );
|
||||
script->flags = 0; /* mark script struct for deletion */
|
||||
error( "Python script error: check console" );
|
||||
SCRIPT_SET_NULL(script);
|
||||
error_pyscript();
|
||||
scrarea_queue_redraw( sc->area );
|
||||
}
|
||||
|
||||
@@ -837,7 +838,7 @@ static void exec_but_callback(void *pyobj, void *data)
|
||||
if (!result) {
|
||||
Py_DECREF(pyvalue);
|
||||
PyErr_Print( );
|
||||
error( "Python script error: check console" );
|
||||
error_pyscript( );
|
||||
}
|
||||
Py_XDECREF( result );
|
||||
}
|
||||
@@ -1109,7 +1110,7 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
|
||||
|
||||
if (!result) {
|
||||
PyErr_Print( );
|
||||
error( "Python script error: check console" );
|
||||
error_pyscript( );
|
||||
} else {
|
||||
/* copied from do_clever_numbuts in toolbox.c */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user