Page MenuHome

Fix T93629: Reset to defaults undoes all steps when applied twice
AbandonedPublic

Authored by Pratik Borhade (PratikPB2123) on Feb 19 2022, 8:02 PM.

Details

Summary

Fix T93629.

On executing reset_default_button,
We iterate below from active step to find the target step in BKE_undosys_step_load_data_ex
But active and target are on same level if values are already reset.
In this case, we reached to the first step (element of stack) when searching for target step.
So check if target and active steps are on level

Diff Detail

Repository
rB Blender

Event Timeline

Pratik Borhade (PratikPB2123) requested review of this revision.Feb 19 2022, 8:02 PM
Pratik Borhade (PratikPB2123) created this revision.

@Pratik Borhade (PratikPB2123) thanks for looking into this, this change seems reasonable and could even go further to ensure the undo_step_target is before the wm->undo_stack->step_active (or use a search that only looks at steps before wm->undo_stack->step_active).

However the root cause of the bug is that resetting to default leaves the undo stack in an invalid state where the active undo step is set to the previous step.

Output from running Blender ./blender.bin -d --log "ed.undo.*" --log-level 1

Undo 3 Steps (*: active, #=applied, M=memfile-active, S=skip)
[  M ]   0 {0x60f00007d028} type='Global Undo', name='Original'
[*   ]   1 {0x61000037d478} type='Edit Mesh', name='Toggle Edit Mode'
[    ]   2 {0x610000072878} type='Edit Mesh', name='Loop Cut and Slide'
Campbell Barton (campbellbarton) abandoned this revision.EditedFeb 22 2022, 6:45 AM

Committed an alternate fix, rBc5b66560de75a54b5c6920fb675c0d804caeb724 closing.

Note that ed_undo_step_by_name could take a direction argument to search before/after the active undo step to prevent redo ever using an undo state from the future.

Ok, Thanks for reviewing :)