add warning about misuse of ID.user_clear() since it can crash blender.
This commit is contained in:
19
doc/python_api/examples/bpy.types.ID.user_clear.1.py
Normal file
19
doc/python_api/examples/bpy.types.ID.user_clear.1.py
Normal file
@@ -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)
|
@@ -74,10 +74,10 @@ else:
|
|||||||
"bpy.props",
|
"bpy.props",
|
||||||
"bpy.utils",
|
"bpy.utils",
|
||||||
"bpy.context",
|
"bpy.context",
|
||||||
"bpy.types", # supports filtering
|
#"bpy.types", # supports filtering
|
||||||
"bpy.ops", # supports filtering
|
"bpy.ops", # supports filtering
|
||||||
"bpy_extras",
|
"bpy_extras",
|
||||||
# "bge",
|
"bge",
|
||||||
"aud",
|
"aud",
|
||||||
"bgl",
|
"bgl",
|
||||||
"blf",
|
"blf",
|
||||||
@@ -85,7 +85,7 @@ else:
|
|||||||
"mathutils.geometry",
|
"mathutils.geometry",
|
||||||
)
|
)
|
||||||
|
|
||||||
FILTER_BPY_TYPES = ("bpy_struct", "Panel", "Menu", "Operator", "RenderEngine") # allow
|
FILTER_BPY_TYPES = ("bpy_struct", "Panel", "ID") # allow
|
||||||
FILTER_BPY_OPS = ("import.scene", ) # allow
|
FILTER_BPY_OPS = ("import.scene", ) # allow
|
||||||
|
|
||||||
# for quick rebuilds
|
# for quick rebuilds
|
||||||
@@ -744,6 +744,8 @@ def pyrna2sphinx(BASEPATH):
|
|||||||
descr = prop.name
|
descr = prop.name
|
||||||
fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
|
fw(" `%s`, %s, %s\n\n" % (prop.identifier, descr, type_descr))
|
||||||
|
|
||||||
|
write_example_ref(" ", fw, "bpy.types." + struct.identifier + "." + func.identifier)
|
||||||
|
|
||||||
fw("\n")
|
fw("\n")
|
||||||
|
|
||||||
# python methods
|
# python methods
|
||||||
|
Reference in New Issue
Block a user