From 1657cbe61a756222feac5107f87d0d699a92b4a6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Sep 2011 12:22:19 +0000 Subject: fix [#28672] Blender segfault after exiting a game that was opened with autoplay on (Blender, not blenderplayer) blender now stops the sound system and free's its self on Pythons sys.exit(). --- source/blender/windowmanager/WM_api.h | 1 + source/blender/windowmanager/intern/wm_init_exit.c | 28 ++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 5bdf1ec2787..9e19a057175 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -72,6 +72,7 @@ void WM_setinitialstate_fullscreen(void); void WM_setinitialstate_normal(void); void WM_init (struct bContext *C, int argc, const char **argv); +void WM_exit_ext (struct bContext *C, const short do_python); void WM_exit (struct bContext *C); void WM_main (struct bContext *C); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 365301538b0..837b7eb1f2f 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -342,7 +342,8 @@ extern void free_fmodifiers_copybuf(void); extern void free_posebuf(void); /* called in creator.c even... tsk, split this! */ -void WM_exit(bContext *C) +/* note, doesnt run exit() call WM_exit() for that */ +void WM_exit_ext(bContext *C, const short do_python) { wmWindow *win; @@ -408,14 +409,17 @@ void WM_exit(bContext *C) #ifdef WITH_PYTHON - /* XXX - old note */ - /* before free_blender so py's gc happens while library still exists */ - /* needed at least for a rare sigsegv that can happen in pydrivers */ - - /* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's - * so decref'ing them after python ends causes bad problems every time - * the pyDriver bug can be fixed if it happens again we can deal with it then */ - BPY_python_end(); + /* option not to close python so we can use 'atexit' */ + if(do_python) { + /* XXX - old note */ + /* before free_blender so py's gc happens while library still exists */ + /* needed at least for a rare sigsegv that can happen in pydrivers */ + + /* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's + * so decref'ing them after python ends causes bad problems every time + * the pyDriver bug can be fixed if it happens again we can deal with it then */ + BPY_python_end(); + } #endif GPU_global_buffer_pool_free(); @@ -460,6 +464,10 @@ void WM_exit(bContext *C) getchar(); } #endif - exit(G.afbreek==1); } +void WM_exit(bContext *C) +{ + WM_exit_ext(C, 1); + exit(G.afbreek==1); +} -- cgit v1.2.3