Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix headless mode detection in EditorNode

kobewi4521414c6d0e
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 115fe2d3512..588b54928bc 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1053,7 +1053,7 @@ void EditorNode::_notification(int p_what) {
// Save the project after opening to mark it as last modified, except in headless mode.
// Also use this opportunity to ensure default settings are applied to new projects created from the command line
// using `touch project.godot`.
- if (DisplayServer::get_singleton()->window_can_draw()) {
+ if (!cmdline_mode) {
const String project_settings_path = ProjectSettings::get_singleton()->get_resource_path().path_join("project.godot");
// Check the file's size in bytes as an optimization. If it's under 10 bytes, the file is assumed to be empty.
if (FileAccess::get_size(project_settings_path) < 10) {
@@ -8396,9 +8396,7 @@ EditorNode::EditorNode() {
singleton = this;
// Detecting headless mode, that means the editor is running in command line.
- if (!DisplayServer::get_singleton()->window_can_draw()) {
- cmdline_mode = true;
- }
+ cmdline_mode = (DisplayServer::get_singleton()->get_name() == "headless");
Resource::_get_local_scene_func = _resource_get_edited_scene;