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>2008-03-15 21:53:42 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-03-15 21:53:42 +0300
commita5d31fc28e7737b9e6ef3d56986cb2e2f0493047 (patch)
tree2a18763786ebde101e521a82c6eeed83d578ccac /source/blender/python
parent02295c491f610834463f64181768cd12ecfe1278 (diff)
fix for [#8559] Python script that uses FIleSelector and has an error in it segfaults Blender
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/BPY_extern.h4
-rw-r--r--source/blender/python/BPY_interface.c22
-rw-r--r--source/blender/python/api2_2x/Draw.c7
3 files changed, 18 insertions, 15 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index d7bd4f22fc6..bf7c4d7ad62 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -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); */
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index f99a804d75f..d4a894e7661 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -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");
+}
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index a4bbeba65ac..76e33a1bcb7 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -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 */