Blender doesn't undo properties in EDIT mode (looking for someone with blender code knowledge)

I guess it is known issue and undo system limitation that if you edit some property when you’re in edit mode (for example if you change object’s location) and then undo (and if the last undo operation wasn’t edit mode toggle) those properties won’t be affected by undo.

My questions is what properties are affected by undo in EDIT mode? Maybe it’s possible to store data somewhere else in blender I guess besides scene/object properties and expect it to be restored on undo?
Or in edit mode undo system stores only edit mesh / bmesh changes?

1 Like

Hi,

Have you tested it in the Blender 3.6.0? I just tested it in there, switched to the Edit Mode, changed object’s location and then pressed CTRL+Z and it works

I think you’ve missed important step “the last undo operation shouldn’t be edit mode toggle”. If you add some other operator after toggle you’d be able to reproduce the issue.

1 Like

Here’s my attempt to replicate what you did:

Correct if I’m wrong, but it seems like it works in my case

yes, this is the issue - it doesn’t undo properties until you completely undo entering edit mode.

Gotcha

You mean when I do the last undo in retrieves me back to an Object Mode, is that right?

Yes, correct.

I’ve noticed that whether you’re gonna be in an Edit Mode or Sculpt, if you will press CTRL+Z it will take you back to an Object Mode even if you haven’t added any of changes.

You can disable this feature by unchecking Undo option in your Keymap settings. But, it will also disable undo functionality as well. Dunno why. It seems to me like both these functions are split with each other using by the same key.

Based on that, I can assume that maybe it’s just how it should be working, or, if you think that it’s a bug or something - you can report about it straightly from Blender interface:

Report a bug

It’s already reported to blender and it’s considered not a bug but an undo system limitation.
What I’m looking for is to understand more specifically the limits of this issue.

1 Like

I suggest either https://blender.chat/channel/python, https://blender.chat/channel/blender-coders or https://devtalk.blender.org/ for this topic, I don’t think there is currently many (or any) developer with knowledge of the C codebase over here.

1 Like

I encountered the same problem with an addon I’m working on. The addon has an operator that, when run from Edit Mode:

  1. switches from Edit Mode to Object Mode
  2. performs an operation (it must be performed in Object Mode not in Edit Mode) that moves the active object’s location
  3. switches from Object Mode back to Edit Mode

If you run this operator and then undo, the change to the active object’s transform that it did while it was in object mode doesn’t get undone.

I scoured the web for days searching for a workaround to this Blender undo system limitation to no avail. What can be done about this?

Another (similar) issue caused by this limitation of the undo system: https://projects.blender.org/blender/blender/issues/108638

First of all, as undo problems in EDIT mode is a known limitation then preferably in edit mode user should be doing only edit mode related operations to avoid meething those kind of issues.

But I think there could be a workaround for your case, you can try to create a new undo step (see bpy.ops.ed.undo_push) after you switched to OBJECT mode, so this undo step won’t be related to EDIT mode and won’t have the limitation. Haven’t tested it though, just an idea.

1 Like

This works, but it’s not suitable for my use case because it makes the operator produce 2 undo steps rather than 1—

  • The user needs to undo twice to undo what the operator did.
  • The “last operator adjustment” panel only goes back 1 undo step when its properties are adjusted, so—since the operator creates 2 undo steps per execution—sliding a slider in the panel causes the undo history to rapidly fill up with steps, ruining the user’s undo history.

I guess this is a necessary evil.

That’s interesting. You added bpy.ops.ed.undo_push to the some property update callback or why this occurs? Maybe there’s some workaround to make sliding create just 1 undo step as it does usually in OBJECT mode.

1 Like