diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-12-13 20:39:01 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-12-13 20:39:01 -0300 |
commit | 7f96f0603e16a970c7b0ea1fba936e56baf80d4a (patch) | |
tree | f470757f0dc5669ed7fbd6c720339dde0d7ce04d /tools/editor/editor_node.cpp | |
parent | 72ff61963b207cc41664f7aeb39448d0a2f8369f (diff) |
-scenes are properly reloaded when a dependency changes, fixes #2896
(it's clevery done so local changes to scenes are kept even if unsaved)
Diffstat (limited to 'tools/editor/editor_node.cpp')
-rw-r--r-- | tools/editor/editor_node.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 3dbca760f0..05df0a3e48 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -955,7 +955,23 @@ void EditorNode::_save_scene(String p_file) { _set_scene_metadata(); - Ref<PackedScene> sdata = memnew( PackedScene ); + + + Ref<PackedScene> sdata; + + if (ResourceCache::has(p_file)) { + // something may be referencing this resource and we are good with that. + // we must update it, but also let the previous scene state go, as + // old version still work for referencing changes in instanced or inherited scenes + + sdata = Ref<PackedScene>( ResourceCache::get(p_file)->cast_to<PackedScene>() ); + if (sdata.is_valid()) + sdata->recreate_state(); + else + sdata.instance(); + } else { + sdata.instance(); + } Error err = sdata->pack(scene); @@ -3414,8 +3430,18 @@ void EditorNode::set_current_version(uint64_t p_version) { bool EditorNode::is_changing_scene() const { return changing_scene; } + +void EditorNode::_clear_undo_history() { + + get_undo_redo()->clear_history(); +} + void EditorNode::set_current_scene(int p_idx) { + if (editor_data.check_and_update_scene(p_idx)) { + call_deferred("_clear_undo_history"); + } + changing_scene=true; editor_data.save_edited_scene_state(editor_selection,&editor_history,_get_main_scene_state()); @@ -4113,6 +4139,7 @@ void EditorNode::_bind_methods() { ObjectTypeDB::bind_method("_toggle_search_bar",&EditorNode::_toggle_search_bar); ObjectTypeDB::bind_method("_clear_search_box",&EditorNode::_clear_search_box); + ObjectTypeDB::bind_method("_clear_undo_history",&EditorNode::_clear_undo_history); ObjectTypeDB::bind_method(_MD("add_editor_import_plugin", "plugin"), &EditorNode::add_editor_import_plugin); ObjectTypeDB::bind_method(_MD("remove_editor_import_plugin", "plugin"), &EditorNode::remove_editor_import_plugin); |