Skip to content

Commit

Permalink
Merge pull request #69284 from gdixr/bugfix-69082
Browse files Browse the repository at this point in the history
Prevent editor crash when deleting children of GraphNode
  • Loading branch information
YuriSizov authored Dec 5, 2022
2 parents 1db23e4 + 8e1138d commit d759210
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions scene/gui/graph_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,38 +366,46 @@ void GraphNode::_notification(int p_what) {
close_rect = Rect2();
}

for (const KeyValue<int, Slot> &E : slot_info) {
if (E.key < 0 || E.key >= cache_y.size()) {
continue;
}
if (!slot_info.has(E.key)) {
continue;
}
const Slot &s = slot_info[E.key];
// Left port.
if (s.enable_left) {
Ref<Texture2D> p = port;
if (s.custom_slot_left.is_valid()) {
p = s.custom_slot_left;
if (get_child_count() > 0) {
for (const KeyValue<int, Slot> &E : slot_info) {
if (E.key < 0 || E.key >= cache_y.size()) {
continue;
}
p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E.key]), s.color_left);
}
// Right port.
if (s.enable_right) {
Ref<Texture2D> p = port;
if (s.custom_slot_right.is_valid()) {
p = s.custom_slot_right;
if (!slot_info.has(E.key)) {
continue;
}
const Slot &s = slot_info[E.key];
// Left port.
if (s.enable_left) {
Ref<Texture2D> p = port;
if (s.custom_slot_left.is_valid()) {
p = s.custom_slot_left;
}
p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E.key]), s.color_left);
}
// Right port.
if (s.enable_right) {
Ref<Texture2D> p = port;
if (s.custom_slot_right.is_valid()) {
p = s.custom_slot_right;
}
p->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E.key]), s.color_right);
}
p->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E.key]), s.color_right);
}

// Draw slot stylebox.
if (s.draw_stylebox) {
Control *c = Object::cast_to<Control>(get_child(E.key));
Rect2 c_rect = c->get_rect();
c_rect.position.x = sb->get_margin(SIDE_LEFT);
c_rect.size.width = w;
draw_style_box(sb_slot, c_rect);
// Draw slot stylebox.
if (s.draw_stylebox) {
Control *c = Object::cast_to<Control>(get_child(E.key));
if (!c || !c->is_visible_in_tree()) {
continue;
}
if (c->is_set_as_top_level()) {
continue;
}
Rect2 c_rect = c->get_rect();
c_rect.position.x = sb->get_margin(SIDE_LEFT);
c_rect.size.width = w;
draw_style_box(sb_slot, c_rect);
}
}
}

Expand Down

0 comments on commit d759210

Please sign in to comment.