Page MenuHome

Fix T60609: Avoid undo push when no changes have been made in color panel
Needs ReviewPublic

Authored by Pratik Borhade (PratikPB2123) on Jun 21 2022, 5:23 PM.

Details

Summary

Use similar logic of pressing ESC key to prevent undo push.
First check if values in panel has been tweaked or not, then set the
menuretval accordingly

Diff Detail

Repository
rB Blender

Event Timeline

Pratik Borhade (PratikPB2123) requested review of this revision.Jun 21 2022, 5:23 PM
Pratik Borhade (PratikPB2123) created this revision.
Campbell Barton (campbellbarton) added inline comments.
source/blender/editors/interface/interface_region_color_picker.cc
874

This line should have a comment that the undo flag gets enabled, with a reference to T60609.

This revision is now accepted and ready to land.Jul 7 2022, 8:47 AM
Campbell Barton (campbellbarton) added inline comments.
source/blender/editors/interface/interface_region_color_picker.cc
874

Normally these kinds of comments don't use the bug as tag, something like this is more in keeping with our current code style.

/* NOTE: The undo flag is enabled if values are edited, see: T60609. */

Campbell Barton (campbellbarton) requested changes to this revision.EditedJul 21 2022, 9:39 AM

Looking into this, it causes the eye-dropper not to undo when activated from the popup.

Pressing escape doesn't do an undo push but clicking away from the popup does, I think we need to change the logic of UI_BLOCK_OUT_1 so it is aware if a change has been made.

This revision now requires changes to proceed.Jul 21 2022, 9:39 AM

Looking into this, it causes the eye-dropper not to undo when activated from the popup.

@Campbell Barton (campbellbarton) , thanks. do you know about any of the case where eyedropper operator is executed but undo-push is intentionally skipped.
I'm talking about this change: rBc8e75c2b00cfb7e87bcb800c9acc8f126949749d (/* Could support finished & undo-skip. */)
Above commit is actually preventing the Undo-push because UI_BUT_UNDO flag is not set
Is it a good idea to remove eye->is_undo = UI_but_flag_is_set(but, UI_BUT_UNDO); ?
or do you expect some other fix?

Pratik Borhade (PratikPB2123) marked 2 inline comments as done.Jul 25 2022, 1:29 PM

@Pratik Borhade (PratikPB2123) I don't know of other cases where this would cause a problem, but I think it's reasonable UI_BUT_UNDO is used as a way to check if changing that setting should undo or not.

Extension the logic that is used with UI_BLOCK_OUT_1 seems like a better solution, to be able to conditionally detect if closing a popup should be considered cancelled or that a change a change was made (as it is with UI_BLOCK_OUT_1).

Pratik Borhade (PratikPB2123) edited the summary of this revision. (Show Details)

Disable UI_BUT_UNDO to avoid undo push if no change has been made in color panel

Disable UI_BUT_UNDO to avoid undo push if no change has been made in color panel

@Campbell Barton (campbellbarton) , like this?

Campbell Barton (campbellbarton) requested changes to this revision.EditedAug 5 2022, 7:25 AM

It shouldn't be necessary to change the button's UI_BUT_UNDO flag as it could interfere with future use of this button (where undo will be expected).

Currently you can open the color popup and press Escape, which wont push an undo step, while moving the mouse out does.

As far as I can see the correct fix is to make moving the mouse away from the popup use an equivalent code path to the logic for pressing Escape, which is - to do nothing but only if nothing was changed.

I'm not too sure on the exact details though, it may mean extending UI_BLOCK_OUT_1 set the menu->menuretval value based on but->changed, this could be default behavior if it doesn't cause problems in other uses of UI_BLOCK_OUT_1, otherwise it could depend on the button type for e.g. So as not to change behavuor of other button types.

This revision now requires changes to proceed.Aug 5 2022, 7:25 AM

Use similar logic of pressing ESC key to prevent undo push.
When esc key is pressed, it sets menu->menuretval to
UI_RETURN_CANCEL, which later sets data->cancel = true
And undo push is not made when cancel is true, see: button_activate_exit