mirror of
https://github.com/godotengine/godot
synced 2024-09-05 17:41:41 +00:00
Fix engine crashing when using Down Arrow selection on Tree with no selection
This commit is contained in:
parent
4119fb32cb
commit
d86e02580c
|
@ -3354,15 +3354,16 @@ void Tree::_go_up() {
|
||||||
prev = selected_item->get_prev_visible();
|
prev = selected_item->get_prev_visible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int col = MAX(selected_col, 0);
|
||||||
|
|
||||||
if (select_mode == SELECT_MULTI) {
|
if (select_mode == SELECT_MULTI) {
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
select_single_item(prev, get_root(), selected_col);
|
select_single_item(prev, get_root(), col);
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
} else {
|
} else {
|
||||||
int col = selected_col < 0 ? 0 : selected_col;
|
|
||||||
while (prev && !prev->cells[col].selectable) {
|
while (prev && !prev->cells[col].selectable) {
|
||||||
prev = prev->get_prev_visible();
|
prev = prev->get_prev_visible();
|
||||||
}
|
}
|
||||||
|
@ -3386,16 +3387,16 @@ void Tree::_go_down() {
|
||||||
next = selected_item->get_next_visible();
|
next = selected_item->get_next_visible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int col = MAX(selected_col, 0);
|
||||||
|
|
||||||
if (select_mode == SELECT_MULTI) {
|
if (select_mode == SELECT_MULTI) {
|
||||||
if (!next) {
|
if (!next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
select_single_item(next, get_root(), selected_col);
|
select_single_item(next, get_root(), col);
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
} else {
|
} else {
|
||||||
int col = selected_col < 0 ? 0 : selected_col;
|
|
||||||
|
|
||||||
while (next && !next->cells[col].selectable) {
|
while (next && !next->cells[col].selectable) {
|
||||||
next = next->get_next_visible();
|
next = next->get_next_visible();
|
||||||
}
|
}
|
||||||
|
@ -4471,7 +4472,7 @@ TreeItem *Tree::get_last_item() const {
|
||||||
while (last) {
|
while (last) {
|
||||||
if (last->next) {
|
if (last->next) {
|
||||||
last = last->next;
|
last = last->next;
|
||||||
} else if (last->first_child) {
|
} else if (last->first_child && !last->collapsed) {
|
||||||
last = last->first_child;
|
last = last->first_child;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue