Merge pull request #71405 from marzecdawid/deselect-root-in-deselect_all

Fix `Tree::deselect_all` not deselecting root
This commit is contained in:
Yuri Sizov 2023-03-27 12:26:41 +02:00 committed by GitHub
commit c0301b74a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4219,15 +4219,21 @@ Tree::SelectMode Tree::get_select_mode() const {
} }
void Tree::deselect_all() { void Tree::deselect_all() {
TreeItem *item = get_next_selected(get_root()); if (root) {
TreeItem *item = root;
while (item) { while (item) {
if (select_mode == SELECT_ROW) {
item->deselect(0);
} else {
for (int i = 0; i < columns.size(); i++) { for (int i = 0; i < columns.size(); i++) {
item->deselect(i); item->deselect(i);
} }
}
TreeItem *prev_item = item; TreeItem *prev_item = item;
item = get_next_selected(get_root()); item = get_next_selected(root);
ERR_FAIL_COND(item == prev_item); ERR_FAIL_COND(item == prev_item);
} }
}
selected_item = nullptr; selected_item = nullptr;
selected_col = -1; selected_col = -1;