Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save external data even without scene #85513

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_nod
return false;
}

int EditorNode::_save_external_resources() {
int EditorNode::_save_external_resources(bool p_also_save_external_data) {
// Save external resources and its subresources if any was modified.

int flg = 0;
Expand Down Expand Up @@ -1739,6 +1739,16 @@ int EditorNode::_save_external_resources() {
saved++;
}

if (p_also_save_external_data) {
for (int i = 0; i < editor_data.get_editor_plugin_count(); i++) {
EditorPlugin *plugin = editor_data.get_editor_plugin(i);
if (!plugin->get_unsaved_status().is_empty()) {
plugin->save_external_data();
saved++;
}
}
}

EditorUndoRedoManager::get_singleton()->set_history_as_saved(EditorUndoRedoManager::GLOBAL_HISTORY);

return saved;
Expand Down Expand Up @@ -2634,10 +2644,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
ScriptEditor::get_singleton()->save_current_script();
}

const int saved = _save_external_resources();
const int saved = _save_external_resources(true);
if (saved > 0) {
show_accept(
vformat(TTR("The current scene has no root node, but %d modified external resource(s) were saved anyway."), saved),
vformat(TTR("The current scene has no root node, but %d modified external resource(s) and/or plugin data were saved anyway."), saved),
TTR("OK"));
} else if (p_option == FILE_SAVE_AS_SCENE) {
// Don't show this dialog when pressing Ctrl + S to avoid interfering with script saving.
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ class EditorNode : public Node {

void _update_undo_redo_allowed();

int _save_external_resources();
int _save_external_resources(bool p_also_save_external_data = false);

void _set_current_scene(int p_idx);
void _set_current_scene_nocheck(int p_idx);
Expand Down
Loading