run python when starting blender like 2.4x does (was start/stopping python for each...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 27 Dec 2008 04:55:45 +0000 (04:55 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 27 Dec 2008 04:55:45 +0000 (04:55 +0000)
This way python can call the operator to run other scripts
eg...
 bpyoperator.SCRIPT_OT_run_pyfile(filename = "myop.py")

source/blender/editors/screen/stubs.c
source/blender/python/intern/bpy_interface.c
source/blender/windowmanager/intern/wm_init_exit.c

index aca51463885336a24df77cd52bc11a6564bf5b16..539add3b3095a59a63238ebb24a2592b8bd95511 100644 (file)
@@ -41,7 +41,7 @@ void *editelems;
 /* python, will come back */
 void BPY_post_start_python() {}
 //void BPY_run_python_script() {}
-void BPY_start_python() {}
+//void BPY_start_python() {}
 void BPY_do_all_scripts() {}
 void BPY_call_importloader() {}
 void BPY_do_pyscript() {}
index 2662890f3c8ef172a8a2e19ddd67e05fc9198d3b..1b4b611120a18bdda03c1672309a0ecbb310b1b5 100644 (file)
@@ -39,10 +39,10 @@ static PyObject *CreateGlobalDictionary( bContext *C )
        return dict;
 }
 
-static void BPY_start_python( void )
+void BPY_start_python( void )
 {
        PyThreadState *py_tstate = NULL;
-       
+
        Py_Initialize(  );
        
        //PySys_SetArgv( argc_copy, argv_copy );
@@ -57,7 +57,7 @@ static void BPY_start_python( void )
        
 }
 
-static void BPY_end_python( void )
+void BPY_end_python( void )
 {
        PyGILState_Ensure(); /* finalizing, no need to grab the state */
        
@@ -76,7 +76,7 @@ void BPY_run_python_script( bContext *C, const char *fn )
        /* TODO - look into a better way to run a file */
        sprintf(pystring, "exec(open(r'%s').read())", fn);      
        
-       BPY_start_python();
+       //BPY_start_python();
        
        gilstate = PyGILState_Ensure();
        
@@ -91,5 +91,5 @@ void BPY_run_python_script( bContext *C, const char *fn )
        
        PyGILState_Release(gilstate);
        
-       BPY_end_python();
+       //BPY_end_python();
 }
index 5e61900ddc738424e421887dc8b01c8290f00d9c..274595cc2f177b7c72536fe50c4b36b910462eaf 100644 (file)
@@ -211,7 +211,7 @@ void WM_exit(bContext *C)
        
        /* before free_blender so py's gc happens while library still exists */
        /* needed at least for a rare sigsegv that can happen in pydrivers */
-//     BPY_end_python();
+       BPY_end_python();
        
 //     fastshade_free_render();        /* shaded view */
        free_blender();                         /* blender.c, does entire library */