Merge pull request #86028 from jsjtxietian/prevent-crash-when-notify-change-empty-tree

Prevent crash when calling `set_text()` on a removed TreeItem
This commit is contained in:
Rémi Verschelde 2023-12-13 10:32:48 +01:00
commit 2d5ceaab3e
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 12 additions and 4 deletions

View File

@ -70,19 +70,27 @@ void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Si
}
void TreeItem::_changed_notify(int p_cell) {
tree->item_changed(p_cell, this);
if (tree) {
tree->item_changed(p_cell, this);
}
}
void TreeItem::_changed_notify() {
tree->item_changed(-1, this);
if (tree) {
tree->item_changed(-1, this);
}
}
void TreeItem::_cell_selected(int p_cell) {
tree->item_selected(p_cell, this);
if (tree) {
tree->item_selected(p_cell, this);
}
}
void TreeItem::_cell_deselected(int p_cell) {
tree->item_deselected(p_cell, this);
if (tree) {
tree->item_deselected(p_cell, this);
}
}
void TreeItem::_change_tree(Tree *p_tree) {