Fix headless import always emits errors

This commit is contained in:
Hilderin 2025-02-28 11:11:10 -05:00
parent 1753893c60
commit dba92c9354
2 changed files with 12 additions and 7 deletions

View file

@ -1207,7 +1207,7 @@ void EditorNode::_sources_changed(bool p_exist) {
}
// Start preview thread now that it's safe.
if (!singleton->cmdline_export_mode) {
if (!singleton->cmdline_mode) {
EditorResourcePreview::get_singleton()->start();
}
@ -1807,7 +1807,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
save_scene_progress->step(TTR("Saving Scene"), 4);
_save_scene(p_file, p_idx);
if (!singleton->cmdline_export_mode) {
if (!singleton->cmdline_mode) {
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
}
@ -4944,7 +4944,7 @@ bool EditorNode::is_object_of_custom_type(const Object *p_object, const StringNa
void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) {
if (!singleton) {
return;
} else if (singleton->cmdline_export_mode) {
} else if (singleton->cmdline_mode) {
print_line(p_task + ": begin: " + p_label + " steps: " + itos(p_steps));
} else if (singleton->progress_dialog) {
singleton->progress_dialog->add_task(p_task, p_label, p_steps, p_can_cancel);
@ -4954,7 +4954,7 @@ void EditorNode::progress_add_task(const String &p_task, const String &p_label,
bool EditorNode::progress_task_step(const String &p_task, const String &p_state, int p_step, bool p_force_refresh) {
if (!singleton) {
return false;
} else if (singleton->cmdline_export_mode) {
} else if (singleton->cmdline_mode) {
print_line("\t" + p_task + ": step " + itos(p_step) + ": " + p_state);
return false;
} else if (singleton->progress_dialog) {
@ -4967,7 +4967,7 @@ bool EditorNode::progress_task_step(const String &p_task, const String &p_state,
void EditorNode::progress_end_task(const String &p_task) {
if (!singleton) {
return;
} else if (singleton->cmdline_export_mode) {
} else if (singleton->cmdline_mode) {
print_line(p_task + ": end");
} else if (singleton->progress_dialog) {
singleton->progress_dialog->end_task(p_task);
@ -5220,7 +5220,7 @@ Error EditorNode::export_preset(const String &p_preset, const String &p_path, bo
export_defer.android_build_template = p_android_build_template;
export_defer.patch = p_patch;
export_defer.patches = p_patches;
cmdline_export_mode = true;
cmdline_mode = true;
return OK;
}
@ -6848,6 +6848,11 @@ EditorNode::EditorNode() {
DEV_ASSERT(!singleton);
singleton = this;
// Detecting headless mode, that means the editor is running in command line.
if (!DisplayServer::get_singleton()->window_can_draw()) {
cmdline_mode = true;
}
Resource::_get_local_scene_func = _resource_get_edited_scene;
{

View file

@ -419,7 +419,7 @@ private:
bool script_distraction_free = false;
bool changing_scene = false;
bool cmdline_export_mode = false;
bool cmdline_mode = false;
bool convert_old = false;
bool immediate_dialog_confirmed = false;
bool opening_prev = false;