diff options
Diffstat (limited to 'source/blender/python/api2_2x/bpy_data.c')
-rw-r--r-- | source/blender/python/api2_2x/bpy_data.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/python/api2_2x/bpy_data.c b/source/blender/python/api2_2x/bpy_data.c index 4705c1bdd03..47232c6707a 100644 --- a/source/blender/python/api2_2x/bpy_data.c +++ b/source/blender/python/api2_2x/bpy_data.c @@ -263,9 +263,12 @@ PyObject *LibBlockSeq_getActive(BPy_LibBlockSeq *self) } break; case ID_TXT: { - SpaceText *st= curarea->spacedata.first; + SpaceText *st = NULL; - if (st->spacetype!=SPACE_TEXT || st->text==NULL) { + if (curarea) + st = curarea->spacedata.first; + + if (st==NULL || st->spacetype!=SPACE_TEXT || st->text==NULL) { Py_RETURN_NONE; } else { return Text_CreatePyObject( st->text ); @@ -330,9 +333,15 @@ static int LibBlockSeq_setActive(BPy_LibBlockSeq *self, PyObject *value) return EXPP_ReturnIntError(PyExc_TypeError, "Must be a text" ); } else { - SpaceText *st= curarea->spacedata.first; + SpaceText *st= NULL; Text *data = ((BPy_Text *)value)->text; + if (curarea==NULL) { + return 0; + } else { + st= curarea->spacedata.first; + } + if( !data ) return EXPP_ReturnIntError( PyExc_RuntimeError, "This object isn't linked to a Blender Text Object" ); |