summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-01-15 12:48:56 +0100
committerGitHub <noreply@github.com>2021-01-15 12:48:56 +0100
commit274db4aa6480a08031d6118a127c70bd78ea602d (patch)
tree1d48c5e92175bf92d3141b67464f1654473fcb64 /scene/gui
parent8a331070868cf4e4c5aa91d20ca3a22a8cc42a8e (diff)
parent5e8e9fc601b41596a264b53fbf7d629a7210cf33 (diff)
Merge pull request #45149 from pycbouh/ge-disconnect-crash
Prevent signal disconnection attempts on invalid references
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/graph_edit.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index d5b12b6bb6..6662992d46 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -401,7 +401,14 @@ void GraphEdit::add_child_notify(Node *p_child) {
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!
}
@@ -409,8 +416,14 @@ void GraphEdit::remove_child_notify(Node *p_child) {
if (gn) {
gn->disconnect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved));
gn->disconnect("raise_request", callable_mp(this, &GraphEdit::_graph_node_raised));
- gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update));
- gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::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", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update));
+ }
+ if (minimap != nullptr && minimap->is_inside_tree()) {
+ gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::update));
+ }
}
}