diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-06-26 06:43:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-06-26 06:43:15 +0400 |
commit | a6fc975d49fb58d9109b30d779c20ba267f060d6 (patch) | |
tree | b7e0bf9392c23fdfe15589a105df738cf221a2cb /source | |
parent | 9be8517ca3c417fe09b74992b28c2348cb4a0b1f (diff) |
join could crash blender in background mode or if the mesh was not in the current scene. added exceptions for both and notes in the EpyDocs.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 19 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Object.py | 3 |
2 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 20a2dd68281..6610a232060 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -2024,7 +2024,11 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args ) Base *temp_base; short type; int i, ok=0, ret_value=0, list_length=0; - + + if( G.background ) + return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, + "cannot join objects in background mode" ) ); + /* Check if the arguments passed to makeParent are valid. */ if( !PyArg_ParseTuple( args, "O", &list ) ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, @@ -2049,12 +2053,16 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args ) return ( EXPP_ReturnPyObjError( PyExc_TypeError, "Base object is not a type blender can join" ) ); + if (object_in_scene( parent, G.scene )==NULL) + return ( EXPP_ReturnPyObjError( PyExc_TypeError, + "object must be in the current scene" ) ); + /* exit editmode so join can be done */ if( G.obedit ) exit_editmode( 1 ); temp_scene = add_scene( "Scene" ); /* make the new scene */ - temp_scene->lay= 2097151; /* all layers on */ + temp_scene->lay= 1; /* all layers on */ /* Check if the PyObject passed in list is a Blender object. */ for( i = 0; i < list_length; i++ ) { @@ -2069,6 +2077,13 @@ static PyObject *Object_join( BPy_Object * self, PyObject * args ) /* List item is an object, is it the same type? */ child = ( Object * ) Object_FromPyObject( py_child ); if (parent->type == child->type) { + + if (object_in_scene( child, G.scene )==NULL) { + free_libblock( &G.main->scene, temp_scene ); + return ( EXPP_ReturnPyObjError( PyExc_TypeError, + "object must be in the current scene" ) ); + } + ok =1; /* Add a new base, then link the base to the temp_scene */ temp_base = MEM_callocN( sizeof( Base ), "pynewbase" ); diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py index 7bee04a2e52..146611674de 100644 --- a/source/blender/python/api2_2x/doc/Object.py +++ b/source/blender/python/api2_2x/doc/Object.py @@ -675,10 +675,13 @@ class Object: @note: Join will only work for object types Mesh, Armature, Curve and Surface, an error will be raised if the object is not of this type. @note: objects in the list will be ignored if they to not match the base object. + @note: objects must be in the current scene to be joined. + @note: this function will not work in background mode (no user interface) @note: An error in the join function input will raise a TypeError, otherwise an error in the data input will raise a RuntimeError, for situations where you don't have tight control on the data that is being joined, you should handel the RuntimeError error, litting the user know the data cant be joined. + This an happen if the data is too large or one of the objects data has a shape key. """ def makeParentDeform(objects, noninverse = 0, fast = 0): |