summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp57
1 files changed, 18 insertions, 39 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index ce5f762b13..46d76a946f 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -797,8 +797,8 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) {
}
if (changed.size()) {
- for (Ref<Resource> E : changed) {
- E->reload_from_file();
+ for (Ref<Resource> &res : changed) {
+ res->reload_from_file();
}
}
}
@@ -914,7 +914,7 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) {
}
}
- for (String &E : scenes) {
+ for (const String &E : scenes) {
reload_scene(E);
}
@@ -926,7 +926,7 @@ void EditorNode::_sources_changed(bool p_exist) {
waiting_for_first_scan = false;
// Reload the global shader variables, but this time
- // loading texures, as they are now properly imported.
+ // loading textures, as they are now properly imported.
RenderingServer::get_singleton()->global_variables_load_settings(true);
// Start preview thread now that it's safe.
@@ -1143,7 +1143,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
file->clear_filters();
List<String> preferred;
- for (String &E : extensions) {
+ for (const String &E : extensions) {
if (p_resource->is_class("Script") && (E == "tres" || E == "res")) {
//this serves no purpose and confused people
continue;
@@ -1259,7 +1259,7 @@ void EditorNode::_get_scene_metadata(const String &p_file) {
cf->get_section_keys("editor_states", &esl);
Dictionary md;
- for (String &E : esl) {
+ for (const String &E : esl) {
Variant st = cf->get_value("editor_states", E);
if (st.get_type() != Variant::NIL) {
md[E] = st;
@@ -1295,7 +1295,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) {
List<Variant> keys;
md.get_key_list(&keys);
- for (Variant &E : keys) {
+ for (const Variant &E : keys) {
cf->set_value("editor_states", E, md[E]);
}
@@ -1334,7 +1334,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
bool ret_changed = false;
List<PropertyInfo> pi;
obj->get_property_list(&pi);
- for (PropertyInfo &E : pi) {
+ for (const PropertyInfo &E : pi) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
@@ -1364,7 +1364,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool>
Dictionary d = obj->get(E.name);
List<Variant> keys;
d.get_key_list(&keys);
- for (Variant &F : keys) {
+ for (const Variant &F : keys) {
Variant v = d[F];
RES res = v;
if (_find_and_save_resource(res, processed, flags)) {
@@ -1520,7 +1520,7 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso
p_resource->get_property_list(&plist);
- for (PropertyInfo &E : plist) {
+ for (const PropertyInfo &E : plist) {
if (E.type == Variant::OBJECT && E.usage & PROPERTY_USAGE_STORAGE && !(E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) {
RES res = p_resource->get(E.name);
if (res.is_null()) {
@@ -1551,11 +1551,11 @@ int EditorNode::_save_external_resources() {
int saved = 0;
List<Ref<Resource>> cached;
ResourceCache::get_cached_resources(&cached);
- for (Ref<Resource> res : cached) {
+ for (const Ref<Resource> &res : cached) {
if (!res->get_path().is_resource_file()) {
continue;
}
- //not only check if this resourec is edited, check contained subresources too
+ //not only check if this resource is edited, check contained subresources too
if (_find_edited_resources(res, edited_subresources)) {
ResourceSaver::save(res->get_path(), res, flg);
saved++;
@@ -1641,7 +1641,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
editor_data.save_editor_external_data();
- for (Ref<AnimatedValuesBackup> E : anim_backups) {
+ for (Ref<AnimatedValuesBackup> &E : anim_backups) {
E->restore();
}
@@ -1883,7 +1883,7 @@ void EditorNode::_dialog_action(String p_file) {
// erase
List<String> keys;
config->get_section_keys(p_file, &keys);
- for (String &E : keys) {
+ for (const String &E : keys) {
config->set_value(p_file, E, Variant());
}
@@ -2532,7 +2532,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
Ref<MeshLibrary> ml(memnew(MeshLibrary));
ResourceSaver::get_recognized_extensions(ml, &extensions);
file_export_lib->clear_filters();
- for (String &E : extensions) {
+ for (const String &E : extensions) {
file_export_lib->add_filter("*." + E);
}
@@ -4054,7 +4054,7 @@ void EditorNode::_build_icon_type_cache() {
List<StringName> tl;
StringName ei = "EditorIcons";
theme_base->get_theme()->get_icon_list(ei, &tl);
- for (StringName &E : tl) {
+ for (const StringName &E : tl) {
if (!ClassDB::class_exists(E)) {
continue;
}
@@ -4783,7 +4783,7 @@ void EditorNode::_update_layouts_menu() {
List<String> layouts;
config.ptr()->get_sections(&layouts);
- for (String &layout : layouts) {
+ for (const String &layout : layouts) {
if (layout == TTR("Default")) {
editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT));
overridden_default_layout = editor_layouts->get_item_count();
@@ -5333,27 +5333,6 @@ void EditorNode::_file_access_close_error_notify(const String &p_str) {
}
void EditorNode::reload_scene(const String &p_path) {
- /*
- * No longer necessary since scenes now reset and reload their internal resource if needed.
- //first of all, reload internal textures, materials, meshes, etc. as they might have changed on disk
-
- List<Ref<Resource>> cached;
- ResourceCache::get_cached_resources(&cached);
- List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used
- for (Ref<Resource> E : cached) {
- if (E->get_path().begins_with(p_path + "::")) { //subresources of existing scene
- to_clear.push_back(E);
- }
- }
-
- //so reload reloads everything, clear subresources of previous scene
- while (to_clear.front()) {
- to_clear.front()->get()->set_path("");
- to_clear.pop_front();
- }
-
- */
-
int scene_idx = -1;
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
if (editor_data.get_scene_path(i) == p_path) {
@@ -6738,7 +6717,7 @@ EditorNode::EditorNode() {
file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
List<String> sexts;
ResourceLoader::get_recognized_extensions_for_type("Script", &sexts);
- for (String &E : sexts) {
+ for (const String &E : sexts) {
file_script->add_filter("*." + E);
}
gui_base->add_child(file_script);