Avoid crash on exiting due to late prints

This commit is contained in:
Pedro J. Estébanez 2023-08-02 11:43:35 +02:00
parent dca12c2e54
commit b3a5e10f4a
1 changed files with 6 additions and 0 deletions

View File

@ -6730,6 +6730,9 @@ void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_err
} }
void EditorNode::_print_handler_impl(const String &p_string, bool p_error, bool p_rich) { void EditorNode::_print_handler_impl(const String &p_string, bool p_error, bool p_rich) {
if (!singleton) {
return;
}
if (p_error) { if (p_error) {
singleton->log->add_message(p_string, EditorLog::MSG_TYPE_ERROR); singleton->log->add_message(p_string, EditorLog::MSG_TYPE_ERROR);
} else if (p_rich) { } else if (p_rich) {
@ -6845,6 +6848,7 @@ EditorNode::EditorNode() {
DisplayServer::get_singleton()->cursor_set_custom_image(Ref<Resource>()); DisplayServer::get_singleton()->cursor_set_custom_image(Ref<Resource>());
} }
DEV_ASSERT(!singleton);
singleton = this; singleton = this;
EditorUndoRedoManager::get_singleton()->connect("version_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed)); EditorUndoRedoManager::get_singleton()->connect("version_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed));
@ -8210,6 +8214,8 @@ EditorNode::~EditorNode() {
GDExtensionEditorPlugins::editor_node_add_plugin = nullptr; GDExtensionEditorPlugins::editor_node_add_plugin = nullptr;
GDExtensionEditorPlugins::editor_node_remove_plugin = nullptr; GDExtensionEditorPlugins::editor_node_remove_plugin = nullptr;
singleton = nullptr;
} }
/* /*