diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-13 02:48:47 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-13 02:48:47 +0300 |
commit | 98d4da32dd8a2bfea0d830af40f152f7c31f2922 (patch) | |
tree | e3a6d3e112b05d1365b7003ebcbecbe4a3807c96 | |
parent | 11f0dd4951b34eec6d5a12733ef75f1302acbf6d (diff) | |
parent | a67067253b85aba5b3934fd749f589ebabfdc48b (diff) |
Merge branch 'property-search-highlight-tabs' into property-search-all-tabs
-rw-r--r-- | source/blender/editors/interface/interface.c | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 23 |
3 files changed, 22 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b0530c797a8..98140a2c058 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3931,6 +3931,7 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type) const bool found_layout = ui_layout_replace_but_ptr(but->layout, old_but_ptr, but); BLI_assert(found_layout); UNUSED_VARS_NDEBUG(found_layout); + ui_button_group_replace_but_ptr(but->layout, old_but_ptr, but); } } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index ac5230c551a..adcfeb0ccc3 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -1007,6 +1007,7 @@ void ui_resources_free(void); /* interface_layout.c */ void ui_layout_add_but(uiLayout *layout, uiBut *but); bool ui_layout_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut *new_but); +void ui_button_group_replace_but_ptr(uiLayout *root, const void *old_but_ptr, uiBut *new_but); uiBut *ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 79c560e0eff..b528f9e29b2 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -469,6 +469,22 @@ static void button_group_free(uiButtonGroup *button_group) MEM_freeN(button_group); } +/* This function should be removed whenever #ui_layout_replace_but_ptr is removed. */ +void ui_button_group_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut *new_but) +{ + LISTBASE_FOREACH (uiButtonGroup *, button_group, &layout->root->button_groups) { + LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) { + if (link->data == old_but_ptr) { + link->data = new_but; + return; + } + } + } + + /* The button should be in a group. */ + BLI_assert(false); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -5135,6 +5151,8 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only) /** \name Block Layout Search Filtering * \{ */ +static void layout_root_free(uiLayoutRoot *root); + // #define PROPERTY_SEARCH_USE_TOOLTIPS static bool block_search_panel_label_matches(const uiBlock *block) @@ -5173,7 +5191,7 @@ static void block_search_remove_search_only_roots(uiBlock *block) if (root->search_only) { layout_free_and_hide_buttons(root->layout); BLI_remlink(&block->layouts, root); - MEM_freeN(root); + layout_root_free(root); } } } @@ -5556,8 +5574,6 @@ static void ui_layout_free(uiLayout *layout) static void layout_root_free(uiLayoutRoot *root) { - ui_layout_free(root->layout); - LISTBASE_FOREACH_MUTABLE (uiButtonGroup *, button_group, &root->button_groups) { button_group_free(button_group); } @@ -5760,6 +5776,7 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) /* NULL in advance so we don't interfere when adding button */ ui_layout_end(block, root->layout, r_x, r_y); + ui_layout_free(root->layout); layout_root_free(root); } |