From 04ad42d83bf74f679a4de2e29ee98eb6e97ce996 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 8 Oct 2021 12:27:46 +0200 Subject: [PATCH] UI/Assets: Disable undo for tree item buttons Disables undo for: * The tree row collapsing - which doesn't make sense to undo, isn't supported by the undo system, and just triggers the confirmation prompt when closing the file. * Renaming items - While this may make sense in some cases, users of the tree-view API can explicitly do an undo push. For asset catalogs it's not supported. --- source/blender/editors/interface/tree_view.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/interface/tree_view.cc b/source/blender/editors/interface/tree_view.cc index 8ac69f862c8..3f66810b7f6 100644 --- a/source/blender/editors/interface/tree_view.cc +++ b/source/blender/editors/interface/tree_view.cc @@ -246,6 +246,7 @@ void AbstractTreeViewItem::add_collapse_chevron(uiBlock &block) const &block, UI_BTYPE_BUT_TOGGLE, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr, 0, 0, 0, 0, ""); /* Note that we're passing the tree-row button here, not the chevron one. */ UI_but_func_set(but, collapse_chevron_click_fn, nullptr, nullptr); + UI_but_flag_disable(but, UI_BUT_UNDO); /* Check if the query for the button matches the created button. */ BLI_assert(is_collapse_chevron_but(but)); @@ -313,6 +314,7 @@ void AbstractTreeViewItem::add_rename_button(uiLayout &row) /* Gotta be careful with what's passed to the `arg1` here. Any tree data will be freed once the * callback is executed. */ UI_but_func_rename_set(rename_but, AbstractTreeViewItem::rename_button_fn, rename_but); + UI_but_flag_disable(rename_but, UI_BUT_UNDO); const bContext *evil_C = static_cast(block->evil_C); ARegion *region = CTX_wm_region(evil_C);