Page MenuHome

Object deletion fails in frame_change_pre handler when called from Render Image
Closed, InvalidPublic


System Information
Operating system: Linux-5.4.0-47-generic-x86_64-with-debian-bullseye-sid 64 Bits
Graphics card: GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.100

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-16 21:05, hash: rB27660b3cd90d
Worked: No idea

Short description of error
Rendering an image (F12) runs frame_change_pre handler() (I don't know why, but it seems to do so). The bug is: If frame change routine contains object deletion (using bpy.ops.object.delete()) then that deletion fails when image is rendered.

However, object deletion works correctly when frame_change_pre handler() is called when the frame is changed e.g. in Blender Timeline Editor. It is only the call from Render Image where deletion fails. This bug is an issue when object deletion is followed by object creation -> additional unwanted objects are created at every render.

Exact steps for others to reproduce the error

  • Open attached file (from T79464)
  • Click Run Script
  • Render image

The script in the callback should delete the "Cube" object (once it is selected), but no object is deleted.

Event Timeline

bpy.ops.object.delete internally calls the C equivalent for bpy.context.select_objects.
However, the callbacks in frame_change_pre are not called in the main thread and therefore most members of bpy.context cannot be accessed (See rBcf64a5b6).
You can override the context, or not use operators

Closing since this is not a bug but it is by design.