diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 18fa1ff4708..647f7484692 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -354,6 +354,16 @@ void EditorNode::_update_title() { } } +void EditorNode::_update_unsaved_cache() { + bool is_unsaved = EditorUndoRedoManager::get_singleton()->is_history_unsaved(EditorUndoRedoManager::GLOBAL_HISTORY) || + EditorUndoRedoManager::get_singleton()->is_history_unsaved(editor_data.get_current_edited_scene_history_id()); + + if (unsaved_cache != is_unsaved) { + unsaved_cache = is_unsaved; + _update_title(); + } +} + void EditorNode::input(const Ref &p_event) { // EditorNode::get_singleton()->set_process_input is set to true in ProgressDialog // only when the progress dialog is visible. @@ -692,13 +702,6 @@ void EditorNode::_notification(int p_what) { } break; case NOTIFICATION_PROCESS: { - bool global_unsaved = EditorUndoRedoManager::get_singleton()->is_history_unsaved(EditorUndoRedoManager::GLOBAL_HISTORY); - bool scene_or_global_unsaved = global_unsaved || EditorUndoRedoManager::get_singleton()->is_history_unsaved(editor_data.get_current_edited_scene_history_id()); - if (unsaved_cache != scene_or_global_unsaved) { - unsaved_cache = scene_or_global_unsaved; - _update_title(); - } - if (editor_data.is_scene_changed(-1)) { scene_tabs->update_scene_tabs(); } @@ -1975,6 +1978,7 @@ int EditorNode::_save_external_resources(bool p_also_save_external_data) { } EditorUndoRedoManager::get_singleton()->set_history_as_saved(EditorUndoRedoManager::GLOBAL_HISTORY); + _update_unsaved_cache(); return saved; } @@ -2094,6 +2098,7 @@ void EditorNode::_save_scene(String p_file, int idx) { } scene->propagate_notification(NOTIFICATION_EDITOR_POST_SAVE); + _update_unsaved_cache(); } void EditorNode::save_all_scenes() { @@ -3066,6 +3071,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } } + _update_unsaved_cache(); } break; case SCENE_REDO: { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); @@ -3092,6 +3098,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } } + _update_unsaved_cache(); } break; case SCENE_RELOAD_SAVED_SCENE: { @@ -4119,6 +4126,7 @@ void EditorNode::_set_current_scene_nocheck(int p_idx) { } _update_undo_redo_allowed(); + _update_unsaved_cache(); } void EditorNode::setup_color_picker(ColorPicker *p_picker) { @@ -7284,7 +7292,9 @@ EditorNode::EditorNode() { add_child(epnp); 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_unsaved_cache)); EditorUndoRedoManager::get_singleton()->connect("history_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed)); + EditorUndoRedoManager::get_singleton()->connect("history_changed", callable_mp(this, &EditorNode::_update_unsaved_cache)); ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &EditorNode::_update_from_settings)); GDExtensionManager::get_singleton()->connect("extensions_reloaded", callable_mp(this, &EditorNode::_gdextensions_reloaded)); diff --git a/editor/editor_node.h b/editor/editor_node.h index 835a4bf8a22..eeb232c033c 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -566,6 +566,7 @@ private: void _save_editor_states(const String &p_file, int p_idx = -1); void _load_editor_plugin_states_from_config(const Ref &p_config_file); void _update_title(); + void _update_unsaved_cache(); void _version_control_menu_option(int p_idx); void _close_messages(); void _show_messages();