Made blender python work in background mode without a blend file loading.

Blender.c python initialization creates a scene when in background mode and when there is no scene.
Needed to skip redrawing when in background mode because it depended on screen data that wasnt there.
This commit is contained in:
2006-03-24 15:46:26 +00:00
parent 7417d07482
commit d29503cc6d
3 changed files with 16 additions and 14 deletions

View File

@@ -625,14 +625,7 @@ static PyObject *Blender_Save( PyObject * self, PyObject * args )
disable_where_script( 1 ); /* to avoid error popups in the write_* functions */
if( BLI_testextensie( fname, ".blend" ) ) {
/* fix for people who save a new blend in background mode. */
if (!G.scene) {
Scene *scene;
scene= add_scene("Scene");
}
if( BLI_testextensie( fname, ".blend" ) ) {
if( G.fileflags & G_AUTOPACK )
packAll( );
if( !BLO_write_file( fname, G.fileflags, &error ) ) {
@@ -816,7 +809,17 @@ void M_Blender_Init(void)
{
PyObject *module;
PyObject *dict, *smode, *SpaceHandlers;
/* G.scene should only aver be NULL if blender is executed in
background mode, not loading a blend file and executing a python script eg.
blender -P somescript.py -b
The if below solves the segfaults that happen when python runs and
G.scene is NULL */
if(G.background && G.main->scene.first==0) {
Scene *sce= add_scene("1");
set_scene(sce);
}
module = Py_InitModule3("Blender", Blender_methods,
"The main Blender module");

View File

@@ -414,9 +414,6 @@ static PyObject *M_sys_expandpath( PyObject * self, PyObject * args )
if (!PyArg_ParseTuple( args, "s", &path))
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
if (!G.scene)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"error, load a blend before expending the path." );
BLI_strncpy(expanded, path, FILE_MAXDIR + FILE_MAXFILE);
BLI_convertstringcode(expanded, G.sce, G.scene->r.cfra);

View File

@@ -134,8 +134,10 @@ void set_scene(Scene *sce) /* also see scene.c: set_scene_bg() */
set_radglobal();
/* complete redraw */
allqueue(REDRAWALL, 0);
allqueue(REDRAWDATASELECT, 0); /* does a remake */
if (!G.background) {
allqueue(REDRAWALL, 0);
allqueue(REDRAWDATASELECT, 0); /* does a remake */
}
}