Merge pull request #45150 from pycbouh/ge-disconnect-crash-3.2

[3.2] Prevent signal disconnection attempts on invalid references
This commit is contained in:
Rémi Verschelde 2021-01-15 12:49:17 +01:00 committed by GitHub
commit 258f41c024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -414,7 +414,14 @@ void GraphEdit::remove_child_notify(Node *p_child) {
Control::remove_child_notify(p_child);
if (is_inside_tree()) {
if (p_child == top_layer) {
top_layer = nullptr;
minimap = nullptr;
} else if (p_child == connections_layer) {
connections_layer = nullptr;
}
if (top_layer != nullptr && is_inside_tree()) {
top_layer->call_deferred("raise"); // Top layer always on top!
}
@ -422,8 +429,14 @@ void GraphEdit::remove_child_notify(Node *p_child) {
if (gn) {
gn->disconnect("offset_changed", this, "_graph_node_moved");
gn->disconnect("raise_request", this, "_graph_node_raised");
gn->disconnect("item_rect_changed", connections_layer, "update");
gn->disconnect("item_rect_changed", minimap, "update");
// In case of the whole GraphEdit being destroyed these references can already be freed.
if (connections_layer != nullptr && connections_layer->is_inside_tree()) {
gn->disconnect("item_rect_changed", connections_layer, "update");
}
if (minimap != nullptr && minimap->is_inside_tree()) {
gn->disconnect("item_rect_changed", minimap, "update");
}
}
}