Scripting: undo after mesh.separate causes crash #106248
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106248
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Linux
Blender Version
Latest tested: blender-3.5.0-beta+v35.f23e3c7f04f3-linux.x86_64-release
Earliest tested: blender-3.1.2-linux-x64
Short description of error
Trying to undo
bpy.ops.mesh.separate(type='MATERIAL')
in a script crashes Blender.Exact steps for others to reproduce the error
Create a cube and two materials. Go to edit mode and assign some faces to both materials. Go back to object mode.
Open the Text Editor and run this script
Crash (segmentation fault).
Somewhat mysteriously if I save just before running the script, close Blender, then reopen the .blend and then run the script, I get non-determinstic results (sometimes the undo does nothing, sometimes the white part is gone). The only consistent way I found to get a crash was to create the cube from scratch every time. So no .blend is attached to this issue.
Can confirm
@mont29 : does this crash sound like High priority to you?
Please always attach a blendfile, this makes reproducing way simpler and faster.
Also, the issue here is getting out of Editmode, then running the script.
106248.blend
This was mentioned here
Sorry if I dont get this right: what does this mean? This is then still wrong, see the comment above (non-determinstic results)
It is not wrong, open that blendfile, go in/out of Edit mode, run the script, crash
Ah, OK, sorry for my confusion
@scurest I would consider this case as unsupported tbh.
Thing is, running the script from the text editor is already running an operator, so all the operator calls you are doing here are done as sub-level calls of the main operator.
The WindowManager handles undo automatically for operators, ensuring that undo steps are only created after executing top-level operators, and none of their potential operators sub-calls inside the top-level one.
So calling things like
bpy.ops.ed.undo_push
andbpy.ops.ed.undo
here is enforcing undo stack operations in a context which does not support them.In general, usage of
bpy.ops.ed.undo
related operators should be very carefully weighted, these should almost never be needed in a normal usage case.Okay. Can it produce an error instead of crashing?