From da3c44958e7264d2cb7cd98615b4d1d05cc02a96 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Apr 2008 14:10:40 +0000 Subject: Bugfix for [#8962] Blender crashes on joining meshes with python blenders screen needs initializing before running python scripts when not in background mode. --- source/creator/creator.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'source/creator') diff --git a/source/creator/creator.c b/source/creator/creator.c index 7607d1026f8..24cdfe88940 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -256,9 +256,20 @@ static void print_help(void) double PIL_check_seconds_timer(void); extern void winlay_get_screensize(int *width_r, int *height_r); +static void main_init_screen( void ) +{ + setscreen(G.curscreen); + + if(G.main->scene.first==0) { + set_scene( add_scene("1") ); + } + + screenmain(); +} + int main(int argc, char **argv) { - int a, i, stax=0, stay=0, sizx, sizy; + int a, i, stax=0, stay=0, sizx, sizy, scr_init = 0; SYS_SystemHandle syshandle; Scene *sce; @@ -649,7 +660,14 @@ int main(int argc, char **argv) break; case 'P': a++; - if (a < argc) BPY_run_python_script (argv[a]); + if (a < argc) { + /* If we're not running in background mode, then give python a valid screen */ + if ((G.background==0) && (scr_init==0)) { + main_init_screen(); + scr_init = 1; + } + BPY_run_python_script (argv[a]); + } else printf("\nError: you must specify a Python script after '-P '.\n"); break; case 'o': @@ -794,16 +812,11 @@ int main(int argc, char **argv) /* actually incorrect, but works for now (ton) */ exit_usiblender(); } - - setscreen(G.curscreen); - - if(G.main->scene.first==0) { - sce= add_scene("1"); - set_scene(sce); + + if (scr_init==0) { + main_init_screen(); } - screenmain(); - return 0; } /* end of int main(argc,argv) */ -- cgit v1.2.3