Fix intermittent crash due to deleted objects

In callbacks and after await, gracefully handle the case where nodes have been
deleted since. This seems to happen sometimes at startup of the editor.
This commit is contained in:
mara 2023-05-27 11:02:43 +00:00
parent f10730918a
commit a5e31e7d36
2 changed files with 8 additions and 2 deletions

View File

@ -86,6 +86,10 @@ func _update_column_sizes():
show()
await get_tree().process_frame
# Abort if the node has been deleted since.
if !is_instance_valid(column_headers[0]):
return
get_parent().custom_minimum_size.y = column_headers[0].size.y
for i in column_headers.size():
column_headers[i].position.x = grid.get_child(i).position.x

View File

@ -47,5 +47,7 @@ func is_text():
func _on_preview_loaded(path : String, preview : Texture, thumbnail_preview : Texture, node):
node.get_node("Box/Tex").visible = true
node.get_node("Box/Tex").texture = preview
# Abort if the node has been deleted since.
if is_instance_valid(node):
node.get_node("Box/Tex").visible = true
node.get_node("Box/Tex").texture = preview