Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tree check propagation not unchecking parent items #79946

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,29 +247,30 @@ void TreeItem::_propagate_check_through_parents(int p_column, bool p_emit_signal
return;
}

bool all_unchecked_and_not_indeterminate = true;
bool any_unchecked_or_indeterminate = false;
bool any_checked = false;
bool any_unchecked = false;
bool any_indeterminate = false;

TreeItem *child_item = current->get_first_child();
while (child_item) {
if (!child_item->is_checked(p_column)) {
any_unchecked_or_indeterminate = true;
any_unchecked = true;
if (child_item->is_indeterminate(p_column)) {
all_unchecked_and_not_indeterminate = false;
any_indeterminate = true;
break;
}
} else {
all_unchecked_and_not_indeterminate = false;
any_checked = true;
}
child_item = child_item->get_next();
}

if (all_unchecked_and_not_indeterminate) {
current->set_checked(p_column, false);
} else if (any_unchecked_or_indeterminate) {
if (any_indeterminate || (any_checked && any_unchecked)) {
current->set_indeterminate(p_column, true);
} else if (current->is_indeterminate(p_column) && !any_checked) {
current->set_indeterminate(p_column, false);
AThousandShips marked this conversation as resolved.
Show resolved Hide resolved
} else {
current->set_checked(p_column, true);
current->set_checked(p_column, any_checked);
}

if (p_emit_signal) {
Expand Down