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:
authorWillian Padovani Germano <wpgermano@gmail.com>2005-10-03 23:12:11 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2005-10-03 23:12:11 +0400
commit080b7f09022f2407eab861e239bc32ef23a15a14 (patch)
treed5756c598b77f05854abecff094304c060910665 /source/blender/python/api2_2x/Blender.c
parentfde63008a590ec32c26b384975012719b5cae7c5 (diff)
BPython bug fixes:
- #2781, reported by Ed Blake: crash on undo when there were active space handlers. Space Handler script links belong to screen areas, which do not get saved on undo. Thanks Ton for pointing out the function that restores ui pointers gone bad. - Applied patch #2822 by Ken Hughes for bug #2647 ("Setting a Face UV"), reported by Campbell Barton. - #3022, reported by Timothy Wakeham: "Blender.BGL.glDrawPixels crashes when drawing more pixels then buffer size". Made glDrawPixels check buffer dimensions. - #2882, reported by Campbell: crash in nmesh.getMaterials(arg == 0 or 1) when nmesh came from GetRawFromMesh(). Raw nmeshes are not linked to Blender meshes, so the method doesn't support these options (getting mat info from the actual mesh) for it. - #2817, reported by Tod Koeckeritz: Dir_Depth var was not being decremented in BPY_Menus.c, causing dir depth limits to be reached prematurely. - #2954, reported by Daniel Holtz: "Python scripts crash hard with valid windows paths". Blender.Load() was not meant for background mode, now it's been update to support it, using BKE_read_file instead of BIF_read_file in this case. Also found another issue with command line scripts using Blender.Load() that could crash Blender: trying to free the Text when it wasn't available anymore (loading a new .blend already removed it). There are still issues with one case, though, causing a crash on start or "Memoryblock winopen: double free" at end, when running a script that is already a Blender Text (only if the script calls Blender.Load, of course). Will investigate. - #2897: reported by Timothy Wakeham: object.setMaterials was asking the length of a Python list w/o confirming first if the passed obj was really a list. Thanks all for the help and for being patient (long delay, again).
Diffstat (limited to 'source/blender/python/api2_2x/Blender.c')
-rw-r--r--source/blender/python/api2_2x/Blender.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 6e3df9394a1..ed8721d511b 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -39,6 +39,7 @@ struct ID; /*keep me up here */
#include "BIF_usiblender.h"
#include "BLI_blenlib.h"
#include "BLO_writefile.h"
+#include "BKE_blender.h"
#include "BKE_exotic.h"
#include "BKE_global.h"
#include "BKE_packedFile.h"
@@ -480,7 +481,7 @@ static PyObject *Blender_Load( PyObject * self, PyObject * args )
if( !PyArg_ParseTuple( args, "|si", &fname, &keep_oldfname ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected filename and optional int or nothing as arguments" );
+ "expected filename and optional int or nothing as arguments" );
if( fname ) {
if( strlen( fname ) > FILE_MAXDIR ) /* G.main->name's max length */
@@ -518,6 +519,7 @@ static PyObject *Blender_Load( PyObject * self, PyObject * args )
is_blend_file = 1; /* no arg given means default: .B.blend */
if( is_blend_file ) {
+
int during_slink = during_scriptlink( );
/* when loading a .blend file from a scriptlink, the scriptlink pointer
@@ -546,21 +548,32 @@ static PyObject *Blender_Load( PyObject * self, PyObject * args )
if( G.obedit )
exit_editmode( 1 );
- /* for safety, any filename with .B.blend is considered the default one.
- * It doesn't seem necessary to compare file attributes (like st_ino and
- * st_dev, according to the glibc info pages) to find out if the given
- * filename, that may have been given with a twisted misgiving path, is the
- * default one for sure. Taking any .B.blend file as the default is good
- * enough here. Note: the default file requires extra clean-up done by
- * BIF_read_homefile: freeing the user theme data. */
- if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
- BIF_read_homefile( );
- else
- BIF_read_file( fname );
+ if (G.background) { /* background mode */
+ if (is_blend_file)
+ BKE_read_file(fname, NULL);
+ else {
+ return EXPP_ReturnPyObjError(PyExc_AttributeError,
+ "only .blend files can be loaded from command line,\n\
+ other file types require interactive mode.");
+ }
+ }
+ else { /* interactive mode */
+ /* for safety, any filename with .B.blend is considered the default one.
+ * It doesn't seem necessary to compare file attributes (like st_ino and
+ * st_dev, according to the glibc info pages) to find out if the given
+ * filename, that may have been given with a twisted misgiving path, is the
+ * default one for sure. Taking any .B.blend file as the default is good
+ * enough here. Note: the default file requires extra clean-up done by
+ * BIF_read_homefile: freeing the user theme data. */
+ if( !fname || ( strstr( fname, ".B.blend" ) && is_blend_file ) )
+ BIF_read_homefile( );
+ else
+ BIF_read_file( fname );
- if( fname && keep_oldfname ) {
- /*BLI_strncpy(G.main->name, name, FILE_MAXDIR); */
- BLI_strncpy( G.sce, name, FILE_MAXDIR );
+ if( fname && keep_oldfname ) {
+ /*BLI_strncpy(G.main->name, name, FILE_MAXDIR); */
+ BLI_strncpy( G.sce, name, FILE_MAXDIR );
+ }
}
Py_INCREF( Py_None );