-
-
Notifications
You must be signed in to change notification settings - Fork 23.7k
Description
Godot version
4.1.1.stable
System information
Any
Issue description
If the root scene being edited is deleted, then the godot editor will crash. This can happen if a tool script has poor logic and calls queue_free() on the edited root scene.
I think the editor should catch this and prevent the crash from happening. It should log an error to the console letting the developer know that they are doing something wrong in their tool scripts.
I've attached a reproducer project that shows this crash. All it really takes is for a tool script to call the queue_free() on itself, but I made it do so after a short duration. Here's the tool script I made.
@tool
extends Sprite2D
var ttl = 3
@onready var child := $Child
func _process(delta):
ttl -= delta# decrement time to live
if ttl <= 0:
if child:
print("deleting child")
child.queue_free()# editor seems to be okay with deleting children
child = null
ttl = 3
else:
print("deleting self")
self.queue_free()# this will crash editor!!!
Steps to reproduce
Create a Node2D scene in the editor.
Attach a script to the node.
Paste the following into the script.
@tool
extends Sprite2D
var ttl = 3
@onready var child := $Child
func _process(delta):
ttl -= delta# decrement time to live
if ttl <= 0:
if child:
print("deleting child")
child.queue_free()# editor seems to be okay with deleting children
child = null
ttl = 3
else:
print("deleting self")
self.queue_free()# this will crash editor!!!
Close the scene and reopen it in the editor.
Wait 6s and the editor should crash.
Minimal reproduction project
Metadata
Metadata
Assignees
Type
Projects
Status