diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-08-23 15:28:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-08-23 15:28:18 +0400 |
commit | 75a63981cd24ccbc8ee38e201c23d70ea449e45f (patch) | |
tree | a88700f3221cc8e1aa379c5403dd6665c883f50a /doc/python_api/examples | |
parent | ce9e4472eb2941881836926ba46ab11203bc61c0 (diff) |
add warning about misuse of ID.user_clear() since it can crash blender.
Diffstat (limited to 'doc/python_api/examples')
-rw-r--r-- | doc/python_api/examples/bpy.types.ID.user_clear.1.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/python_api/examples/bpy.types.ID.user_clear.1.py b/doc/python_api/examples/bpy.types.ID.user_clear.1.py new file mode 100644 index 00000000000..68c35caa7d4 --- /dev/null +++ b/doc/python_api/examples/bpy.types.ID.user_clear.1.py @@ -0,0 +1,19 @@ +""" +User Clear +++++++++++ +This function is for advanced use only, misuse can crash blender since the user +count is used to prevent data being removed when it is used. +""" + +# This example shows what _not_ to do, and will crash blender. +import bpy + +# object which is in the scene. +obj = bpy.data.objects["Cube"] + +# without this, removal would raise an error. +obj.user_clear() + +# runs without an exception +# but will crash on redraw. +bpy.data.objects.remove(obj) |