Python API
authorKen Hughes <khughes@pacific.edu>
Tue, 28 Oct 2008 00:01:20 +0000 (00:01 +0000)
committerKen Hughes <khughes@pacific.edu>
Tue, 28 Oct 2008 00:01:20 +0000 (00:01 +0000)
----------
Bugfix #17911: Mesh.getFromObject() incorrectly decremented the mesh's
material user refcount when the material was linked to the object.

source/blender/python/api2_2x/Mesh.c

index a97a55244ad4d54dc2d7945787c1144cf3913033..32ddb464c88eb5d4e8301032b3c7896212d42540 100644 (file)
@@ -6271,19 +6271,12 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args )
                        if( origmesh->mat ) {
                                for( i = origmesh->totcol; i-- > 0; ) {
                                        /* are we an object material or data based? */
-                                       if (ob->colbits & 1<<i) {
+                                       if (ob->colbits & 1<<i)
                                                self->mesh->mat[i] = ob->mat[i];
-                                               
-                                               if (ob->mat[i])
-                                                       ob->mat[i]->id.us++;
-                                               if (origmesh->mat[i])
-                                                       origmesh->mat[i]->id.us--;
-                                       } else {
+                                       else
                                                self->mesh->mat[i] = origmesh->mat[i];
-                                               
-                                               if (origmesh->mat[i])
-                                                       origmesh->mat[i]->id.us++;
-                                       }
+                                       if (self->mesh->mat[i])
+                                               self->mesh->mat[i]->id.us++;
                                }
                        }
                }