Python API

----------
Bugfix #8472: texture.image setter did not accept None to remove an image, or
set the image type once an image was assigned.
This commit is contained in:
Ken Hughes
2008-03-06 21:43:22 +00:00
parent 08f306c81c
commit ff63ac4bcd
2 changed files with 11 additions and 4 deletions

View File

@@ -1563,16 +1563,23 @@ static int Texture_setImage( BPy_Texture * self, PyObject * value )
{
Image *blimg = NULL;
if( !BPy_Image_Check (value) )
if ( value != Py_None && !BPy_Image_Check (value) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an Image" );
blimg = Image_FromPyObject( value );
"expected an Image or None" );
if( self->texture->ima ) {
self->texture->ima->id.us--;
self->texture->ima = NULL;
}
if ( value == Py_None )
return 0;
blimg = Image_FromPyObject( value );
self->texture->ima = blimg;
self->texture->type = TEX_IMAGE;
BKE_image_signal(blimg, &self->texture->iuser, IMA_SIGNAL_RELOAD );
id_us_plus( &blimg->id );