Python custom Operators fail to Undo properly if executed while in edit mode #59340

Closed
opened 2018-12-14 00:31:22 +01:00 by Roger B · 9 comments

System Information
Operating system: Win10
Graphics card: nVidia Quadro 600

Blender Version
Broken: 2.80 26c8e09cff
Worked: Unknown

Short description of error
Python custom Operators fail to Undo properly if executed while in edit mode

I've provided 3 operators that all show incorrect behavior if executed while you are working in edit mode. They may all be the same systemic issue or different, for now you can take your pick on which, or all, you repro with.

The behavior can change depending on if you use the REGISTER,UNDO tags and if you use a manual bpy.ops.ed.undo_push() (none of which are attempted below) but several tries at addressing the issue have been unsuccessful: https://devtalk.blender.org/t/addon-operators-and-undo-support/4271

Exact steps for others to reproduce the error
undo_repro.blend undo_repro.py

  • Start blender with --factory-startup option

  • Load the attached .blend:

    • Reload this .blend for each individual repro
    • You should be placed in editmode -- this is important. Do not manually switch modes during the repro
  • Invoke 1 of the 3 operators provided by using the built in script editor / py console etc:

    • bpy.ops.view3d.rb_collection_undo_issue() - Adds a new collection to the scene, moves the object named "Cube" to that new collection
    • bpy.ops.view3d.rb_mod_undo_issue() - Adds a modifier to the object named "Cube"
    • bpy.ops.view3d.rb_separate_undo_issue() - Takes currently selected geo and separates into new object
  • Invoke CTRL-Z Undo

    • Notice how none of the actions are undone properly
  • Invoke CTRL-Z Undo a second time; this time the actions are undone because the undo stack passes through the edit-mode toggle as set in the file

    • If you were to perform N other actions between edit-mode toggle and the operator in question, you basically have to CTRL-Z undo N+1 times before the state is undone
**System Information** Operating system: Win10 Graphics card: nVidia Quadro 600 **Blender Version** Broken: 2.80 26c8e09cffd Worked: Unknown **Short description of error** Python custom Operators fail to Undo properly if executed while in edit mode I've provided 3 operators that all show incorrect behavior if executed while you are working in edit mode. They may all be the same systemic issue or different, for now you can take your pick on which, or all, you repro with. The behavior can change depending on if you use the REGISTER,UNDO tags and if you use a manual bpy.ops.ed.undo_push() (_none of which are attempted below_) but several tries at addressing the issue have been unsuccessful: https://devtalk.blender.org/t/addon-operators-and-undo-support/4271 **Exact steps for others to reproduce the error** [undo_repro.blend](https://archive.blender.org/developer/F5947351/undo_repro.blend) [undo_repro.py](https://archive.blender.org/developer/F5947353/undo_repro.py) * Start blender with --factory-startup option * Load the attached .blend: * Reload this .blend for each individual repro * You should be placed in editmode -- this is important. Do not manually switch modes during the repro * Invoke 1 of the 3 operators provided by using the built in script editor / py console etc: * bpy.ops.view3d.rb_collection_undo_issue() - Adds a new collection to the scene, moves the object named "Cube" to that new collection * bpy.ops.view3d.rb_mod_undo_issue() - Adds a modifier to the object named "Cube" * bpy.ops.view3d.rb_separate_undo_issue() - Takes currently selected geo and separates into new object * Invoke CTRL-Z Undo * Notice how none of the actions are undone properly * Invoke CTRL-Z Undo a second time; this time the actions are undone because the undo stack passes through the edit-mode toggle as set in the file * If you were to perform N other actions between edit-mode toggle and the operator in question, you basically have to CTRL-Z undo N+1 times before the state is undone
Author

Added subscriber: @rboxman

Added subscriber: @rboxman

Added subscribers: @brecht, @ZedDB

Added subscribers: @brecht, @ZedDB

I can confirm that I need to invoke undo two times for this to undo properly (or well, not properly in this case).

@brecht who to assign this to?

I can confirm that I need to invoke undo two times for this to undo properly (or well, not properly in this case). @brecht who to assign this to?
Campbell Barton was assigned by Brecht Van Lommel 2018-12-14 13:48:02 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

@ideasman42 worked on the undo system last, and probably knows if this is a bug or a limitation.

@ideasman42 worked on the undo system last, and probably knows if this is a bug or a limitation.
Author

Re-testing now since lots of time has passed. Good news is that the collection issue and the mesh separation issue seem fixed for some simple cases I've tried. Bad news is that the modifier issue still remains and can still be repro'd with the above blend and script.

Re-testing now since lots of time has passed. Good news is that the collection issue and the mesh separation issue seem fixed for some simple cases I've tried. Bad news is that the modifier issue still remains and can still be repro'd with the above blend and script.
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:35:37 +01:00

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sybren A. Stüvel self-assigned this 2020-02-10 16:13:36 +01:00

I re-tested the modifier issue, and I can't reproduce this any more on the current master branch (ec116e3d49), so I'll assume this has been resolved.

Please try the latest daily build: https://builder.blender.org/download/

If the problem persists, please let us know in a comment so we can re-open the report. Don't forget to mention the specific version you tested again.

I re-tested the modifier issue, and I can't reproduce this any more on the current master branch (ec116e3d492511298c9bf595c19e6c49e07c97f6), so I'll assume this has been resolved. Please try the latest daily build: https://builder.blender.org/download/ If the problem persists, please let us know in a comment so we can re-open the report. Don't forget to mention the specific version you tested again.
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#59340
No description provided.