Property Search: Set expansion properly for child panels

Although I haven't seen this cause any visible errors, there is some
incorrect handling for setting panel expansion during search:
 - Properly check if child panel is active first
 - Don't stop traversal at headerless panels that could theoretically
   have children
This commit is contained in:
Hans Goudey 2020-09-29 09:33:48 -05:00
parent bab2260b59
commit ece8f69f85
1 changed files with 9 additions and 11 deletions

View File

@ -846,18 +846,18 @@ bool UI_panel_matches_search_filter(const Panel *panel)
*/
static void panel_set_expansion_from_seach_filter_recursive(const bContext *C, Panel *panel)
{
short start_flag = panel->flag;
SET_FLAG_FROM_TEST(panel->flag, !UI_panel_matches_search_filter(panel), PNL_CLOSED);
if (start_flag != panel->flag) {
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
if (!(panel->type->flag & PNL_NO_HEADER)) {
short start_flag = panel->flag;
SET_FLAG_FROM_TEST(panel->flag, !UI_panel_matches_search_filter(panel), PNL_CLOSED);
if (start_flag != panel->flag) {
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
}
}
/* If the panel is filtered (removed) we need to check that its children are too. */
LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
if (panel->runtime_flag & PANEL_ACTIVE) {
if (!(panel->type->flag & PNL_NO_HEADER)) {
panel_set_expansion_from_seach_filter_recursive(C, child_panel);
}
if (child_panel->runtime_flag & PANEL_ACTIVE) {
panel_set_expansion_from_seach_filter_recursive(C, child_panel);
}
}
}
@ -870,9 +870,7 @@ void UI_panels_set_expansion_from_seach_filter(const bContext *C, ARegion *regio
{
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
if (panel->runtime_flag & PANEL_ACTIVE) {
if (!(panel->type->flag & PNL_NO_HEADER)) {
panel_set_expansion_from_seach_filter_recursive(C, panel);
}
panel_set_expansion_from_seach_filter_recursive(C, panel);
}
}
}