Page MenuHome

user_clear() sets users to zero but doesn't remove links (context pointers)
Closed, ArchivedPublic

Description

e.g. Materials can only be removed if there are 0 users:

mat = bpy.data.materials[0]
mat.user_clear() # make it have zero users
bpy.data.materials.remove(mat) # works since mat has 0 user count

If you then enter and exit edit mode, blender may crash, since the material is still in material slot, but doesn't exist anymore.

Event Timeline

codemanx edited a custom field.May 22 2013, 8:14 PM

It can indeed crash, see the documentation:
http://www.blender.org/documentation/blender_python_api_2_63_17/bpy.types.ID.html#bpy.types.ID.user_clear

Brecht Van Lommel (brecht) changed the task status from Unknown Status to Archived.May 22 2013, 10:08 PM