Skip to content

Commit

Permalink
Fix no unsaved indicator Save As resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilderin committed Aug 31, 2024
1 parent 61598c5 commit d5865c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions editor/editor_resource_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ void EditorResourcePicker::_file_quick_selected() {
_file_selected(quick_open->get_selected());
}

void EditorResourcePicker::_resource_saved(Object *p_resource) {
if (edited_resource != nullptr && p_resource == edited_resource.ptr()) {
emit_signal(SNAME("resource_changed"), edited_resource);
_update_resource();
}
}

void EditorResourcePicker::_update_menu() {
_update_menu_items();

Expand Down Expand Up @@ -408,6 +415,9 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
if (edited_resource.is_null()) {
return;
}
if (!EditorNode::get_singleton()->is_connected("resource_saved", callable_mp(this, &EditorResourcePicker::_resource_saved))) {
EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &EditorResourcePicker::_resource_saved));
}
EditorNode::get_singleton()->save_resource_as(edited_resource);
} break;

Expand Down Expand Up @@ -833,6 +843,12 @@ void EditorResourcePicker::_notification(int p_what) {
assign_button->queue_redraw();
}
} break;

case NOTIFICATION_EXIT_TREE: {
if (EditorNode::get_singleton()->is_connected("resource_saved", callable_mp(this, &EditorResourcePicker::_resource_saved))) {
EditorNode::get_singleton()->disconnect("resource_saved", callable_mp(this, &EditorResourcePicker::_resource_saved));
}
} break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions editor/editor_resource_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class EditorResourcePicker : public HBoxContainer {
void _file_quick_selected();
void _file_selected(const String &p_path);

void _resource_saved(Object *p_resource);

void _update_menu();
void _update_menu_items();
void _edit_menu_cbk(int p_which);
Expand Down

0 comments on commit d5865c0

Please sign in to comment.