From e57ce8489b7fa14f1dd8bd3eebb8e71e92ae9705 Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Tue, 21 Mar 2006 23:30:25 +0000 Subject: [PATCH] ===Python API=== Two small bugfixes: * Image.New() resets id.us to 0; it is set to 1 by new_image() * allow ima.depth and ima.size getters to propagate their own error messages (missing image was returning MemoryError) Also, seems to me there's something funny going on with image id.us accounting. In do_image_buttons(), id.us is set whenever an image is accessed vi the datablock menu: if(idtest!=id) { G.sima->image= (Image *)idtest; if(idtest->us==0) idtest->us= 1; allqueue(REDRAWIMAGE, 0); } This is independent of whether a UV face is selected or not (and it also seems that the number of UV faces linked to an image is not maintained either). --- source/blender/python/api2_2x/Image.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 3d5a2c08df5..1f76ff1c7a3 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -126,7 +126,9 @@ static PyObject *M_Image_New( PyObject * self, PyObject * args) if( !img ) return ( EXPP_ReturnPyObjError( PyExc_MemoryError, "couldn't create PyObject Image_Type" ) ); - + + /* reset usage count, since new_image() incremented it */ + img->id.us--; return Image_CreatePyObject( img ); } @@ -1086,9 +1088,9 @@ static PyObject *Image_getAttr( BPy_Image * self, char *name ) else if( strcmp( name, "filename" ) == 0 ) attr = PyString_FromString( self->image->name ); else if( strcmp( name, "size" ) == 0 ) - attr = Image_getSize( self ); + return Image_getSize( self ); else if( strcmp( name, "depth" ) == 0 ) - attr = Image_getDepth( self ); + return Image_getDepth( self ); else if( strcmp( name, "xrep" ) == 0 ) attr = PyInt_FromLong( self->image->xrep ); else if( strcmp( name, "yrep" ) == 0 )