Fix select_all() crash in RichTextLabel

This commit is contained in:
ConteZero 2022-04-13 14:22:20 +02:00
parent d27f60f0e8
commit 6530e55f2d

View file

@ -4257,7 +4257,7 @@ void RichTextLabel::select_all() {
while (it) { while (it) {
if (it->type != ITEM_FRAME) { if (it->type != ITEM_FRAME) {
if (from_item == nullptr) { if (!from_item) {
from_item = it; from_item = it;
} else { } else {
to_item = it; to_item = it;
@ -4265,13 +4265,22 @@ void RichTextLabel::select_all() {
} }
it = _get_next_item(it, true); it = _get_next_item(it, true);
} }
if (!from_item || !to_item) {
return;
}
ItemFrame *from_frame = nullptr; ItemFrame *from_frame = nullptr;
int from_line = 0; int from_line = 0;
_find_frame(from_item, &from_frame, &from_line); _find_frame(from_item, &from_frame, &from_line);
if (!from_frame) {
return;
}
ItemFrame *to_frame = nullptr; ItemFrame *to_frame = nullptr;
int to_line = 0; int to_line = 0;
_find_frame(to_item, &to_frame, &to_line); _find_frame(to_item, &to_frame, &to_line);
if (!to_frame) {
return;
}
selection.from_line = from_line; selection.from_line = from_line;
selection.from_frame = from_frame; selection.from_frame = from_frame;
selection.from_char = 0; selection.from_char = 0;