1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-26 15:46:23 +00:00

Prevent editor crash when deleting children of GraphNode

This commit is contained in:
zhangjianguo
2022-11-29 09:10:45 +08:00
parent 4a82d71d73
commit 8e1138d59a

View File

@@ -366,38 +366,46 @@ void GraphNode::_notification(int p_what) {
close_rect = Rect2(); close_rect = Rect2();
} }
for (const KeyValue<int, Slot> &E : slot_info) { if (get_child_count() > 0) {
if (E.key < 0 || E.key >= cache_y.size()) { for (const KeyValue<int, Slot> &E : slot_info) {
continue; 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;
} }
p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E.key]), s.color_left); if (!slot_info.has(E.key)) {
} continue;
// Right port. }
if (s.enable_right) { const Slot &s = slot_info[E.key];
Ref<Texture2D> p = port; // Left port.
if (s.custom_slot_right.is_valid()) { if (s.enable_left) {
p = s.custom_slot_right; 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. // Draw slot stylebox.
if (s.draw_stylebox) { if (s.draw_stylebox) {
Control *c = Object::cast_to<Control>(get_child(E.key)); Control *c = Object::cast_to<Control>(get_child(E.key));
Rect2 c_rect = c->get_rect(); if (!c || !c->is_visible_in_tree()) {
c_rect.position.x = sb->get_margin(SIDE_LEFT); continue;
c_rect.size.width = w; }
draw_style_box(sb_slot, c_rect); 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);
}
} }
} }