Page MenuHome

Skip undo steps when changing properties of the 3d cursor through the UI
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Mar 11 2021, 5:12 PM.

Details

Summary

Reinvestigating T57100, I realized that, even though the cursor values
were cleared in the undo steps (in scene_blend_write), an undo step
is always added to the scene when changing the properties of the 3d
cursor on the panel.

This is bad for obvious reasons: overhead, memory, useless Ctrl+Z...

This patch proposes to untag the View3DCursor RNA struct as not having
undo and thus clear the UI_BUT_UNDO flag of the button created in
ui_def_but_rna for the panel.

Diff Detail

Repository
rB Blender

Event Timeline

Germano Cavalcante (mano-wii) requested review of this revision.Mar 11 2021, 5:12 PM
Germano Cavalcante (mano-wii) created this revision.

I would not go that way, starting to not write undo steps even though we edit some undo-affected data is open gate for issues with modern undo system, which is much, much less forgiving to inconsistencies. Let's not open new potential vulnerabilities here, we already have enough to actually fix in undo code, that kind of micro-optimization is really not worth the risk currently.

Understandable, we don't want to risk new gates for bugs.
But by saying "we edit some undo-affected data", I want to make sure that the problem was really understood.
The 3D cursor values are not written as an undo step, they are intentionally set to zero in the undo-step (with memset).
This creates undo steps that have nothing different (besides the name).

Not adding undo-steps would match the operator that changes the 3D cursor position when clicking in the 3D view, as it does not add undo-steps.


This problem is similar to the operator that moves the 3D cursor with hold and drag (bpy.ops.transform.traslate(....)) as it creates problematic undo steps.

@Germano Cavalcante (mano-wii) aaah... yeah I might have been a bit quick on this one, indeed since the cursor3d operator itself does not store undo steps, we can probably do the same for the RNA access to this data.

note that your patch should be committed in two steps though, the fix in interface.c should go first, before making RNA 3Dcursor struct non-undoable.

Cannot reopen it myself, can you do it?

This revision is now accepted and ready to land.Mar 22 2021, 4:26 PM