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>2006-03-24 18:46:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2006-03-24 18:46:26 +0300
commitd29503cc6d96cabe836c011645cde9920ba213b8 (patch)
treed8c2dc9c786d8259a508fea33f4a7b1a5f15344d
parent7417d0748277d8649349a6ef86d44fc76a2d199f (diff)
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.
-rw-r--r--source/blender/python/api2_2x/Blender.c21
-rw-r--r--source/blender/python/api2_2x/Sys.c3
-rw-r--r--source/blender/src/drawscene.c6
3 files changed, 16 insertions, 14 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 5b63a43cd7d..46cb3381e38 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -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");
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c
index 615268504f1..bf676b31be1 100644
--- a/source/blender/python/api2_2x/Sys.c
+++ b/source/blender/python/api2_2x/Sys.c
@@ -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);
diff --git a/source/blender/src/drawscene.c b/source/blender/src/drawscene.c
index 4528c2125f4..330f9d45085 100644
--- a/source/blender/src/drawscene.c
+++ b/source/blender/src/drawscene.c
@@ -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 */
+ }
}