From aa086fa0d504c31120334d687603c50aa0acc4ab Mon Sep 17 00:00:00 2001 From: Mounir Tohami <53877170+WhalesState@users.noreply.github.com> Date: Sat, 26 Jul 2025 14:03:45 +0300 Subject: [PATCH] Fix Editor crash during first scan in headless import mode. --- editor/editor_data.cpp | 1 + editor/editor_node.cpp | 8 -------- main/main.cpp | 3 +++ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 496f3644ca1..79b5a2ae821 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -950,6 +950,7 @@ void EditorData::clear_edited_scenes() { } } edited_scene.clear(); + SceneTree::get_singleton()->set_edited_scene_root(nullptr); } void EditorData::set_plugin_window_layout(Ref p_layout) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 28d02033624..9fbc4fb3069 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5616,14 +5616,6 @@ void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog) { Vector EditorNode::_init_callbacks; void EditorNode::_begin_first_scan() { - // In headless mode, scan right away. - // This allows users to continue using `godot --headless --editor --quit` to prepare a project. - if (!DisplayServer::get_singleton()->window_can_draw()) { - OS::get_singleton()->benchmark_begin_measure("Editor", "First Scan"); - EditorFileSystem::get_singleton()->scan(); - return; - } - if (!waiting_for_first_scan) { return; } diff --git a/main/main.cpp b/main/main.cpp index 36d3c44b764..b6bf1a2646e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1653,6 +1653,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph upwards = true; } else if (arg == "--quit") { // Auto quit at the end of the first main loop iteration quit_after = 1; +#ifdef TOOLS_ENABLED + wait_for_import = true; +#endif } else if (arg == "--quit-after") { // Quit after the given number of iterations if (N) { quit_after = N->get().to_int();