diff --git a/core/config/engine.cpp b/core/config/engine.cpp index c03c872f17a..0b5b5627af8 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -214,7 +214,7 @@ bool Engine::has_singleton(const String &p_name) const { } void Engine::get_singletons(List *p_singletons) { - for (Singleton &E : singletons) { + for (const Singleton &E : singletons) { p_singletons->push_back(E); } } diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 22acb23bce6..c5e6c6d6856 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -800,7 +800,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapkey() != "") { file->store_string("[" + E->key() + "]\n\n"); } - for (String &F : E->get()) { + for (const String &F : E->get()) { String key = F; if (E->key() != "") { key = E->key() + "/" + key; @@ -928,7 +928,7 @@ Vector ProjectSettings::get_optimizer_presets() const { ProjectSettings::get_singleton()->get_property_list(&pi); Vector names; - for (PropertyInfo &E : pi) { + for (const PropertyInfo &E : pi) { if (!E.name.begins_with("optimizer_presets/")) { continue; } diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 7a1ba632336..12fca4215ac 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -75,7 +75,7 @@ Vector _ResourceLoader::get_recognized_extensions_for_type(const String List exts; ResourceLoader::get_recognized_extensions_for_type(p_type, &exts); Vector ret; - for (String &E : exts) { + for (const String &E : exts) { ret.push_back(E); } @@ -91,7 +91,7 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); PackedStringArray ret; - for (String &E : deps) { + for (const String &E : deps) { ret.push_back(E); } @@ -141,7 +141,7 @@ Vector _ResourceSaver::get_recognized_extensions(const RES &p_resource) List exts; ResourceSaver::get_recognized_extensions(p_resource, &exts); Vector ret; - for (String &E : exts) { + for (const String &E : exts) { ret.push_back(E); } return ret; @@ -268,7 +268,7 @@ String _OS::get_name() const { Vector _OS::get_cmdline_args() { List cmdline = OS::get_singleton()->get_cmdline_args(); Vector cmdlinev; - for (String &E : cmdline) { + for (const String &E : cmdline) { cmdlinev.push_back(E); } @@ -1822,7 +1822,7 @@ PackedStringArray _ClassDB::get_class_list() const { PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (StringName &E : classes) { + for (const StringName &E : classes) { ret.set(idx++, E); } @@ -1836,7 +1836,7 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (StringName &E : classes) { + for (const StringName &E : classes) { ret.set(idx++, E); } @@ -1891,7 +1891,7 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const ClassDB::get_signal_list(p_class, &signals, p_no_inheritance); Array ret; - for (MethodInfo &E : signals) { + for (const MethodInfo &E : signals) { ret.push_back(E.operator Dictionary()); } @@ -1902,7 +1902,7 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con List plist; ClassDB::get_property_list(p_class, &plist, p_no_inheritance); Array ret; - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { ret.push_back(E.operator Dictionary()); } @@ -1935,7 +1935,7 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const ClassDB::get_method_list(p_class, &methods, p_no_inheritance); Array ret; - for (MethodInfo &E : methods) { + for (const MethodInfo &E : methods) { #ifdef DEBUG_METHODS_ENABLED ret.push_back(E.operator Dictionary()); #else @@ -1955,7 +1955,7 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, PackedStringArray ret; ret.resize(constants.size()); int idx = 0; - for (String &E : constants) { + for (const String &E : constants) { ret.set(idx++, E); } diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp index b832dd58d58..2353a6ebf8b 100644 --- a/core/debugger/debugger_marshalls.cpp +++ b/core/debugger/debugger_marshalls.cpp @@ -40,7 +40,7 @@ Array DebuggerMarshalls::ResourceUsage::serialize() { Array arr; arr.push_back(infos.size() * 4); - for (ResourceInfo &E : infos) { + for (const ResourceInfo &E : infos) { arr.push_back(E.path); arr.push_back(E.format); arr.push_back(E.type); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 7d3abc9b462..0add12ff3db 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -427,7 +427,7 @@ void RemoteDebugger::_send_resource_usage() { List tinfo; RS::get_singleton()->texture_debug_usage(&tinfo); - for (RS::TextureInfo &E : tinfo) { + for (const RS::TextureInfo &E : tinfo) { DebuggerMarshalls::ResourceInfo info; info.path = E.path; info.vram = E.bytes; diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index cc2974cbdb3..a3a91f12478 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -276,7 +276,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Dictionary d1; d1["name"] = E->key(); Array values; - for (Pair &F : E->get()) { + for (const Pair &F : E->get()) { Dictionary d2; d2["name"] = F.first; d2["value"] = F.second; @@ -294,7 +294,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List utility_func_names; Variant::get_utility_function_list(&utility_func_names); - for (StringName &name : utility_func_names) { + for (const StringName &name : utility_func_names) { Dictionary func; func["name"] = String(name); if (Variant::has_utility_function_return_value(name)) { @@ -362,7 +362,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List member_names; Variant::get_member_list(type, &member_names); - for (StringName &member_name : member_names) { + for (const StringName &member_name : member_names) { Dictionary d2; d2["name"] = String(member_name); d2["type"] = Variant::get_type_name(Variant::get_member_type(type, member_name)); @@ -378,7 +378,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List constant_names; Variant::get_constants_for_type(type, &constant_names); - for (StringName &constant_name : constant_names) { + for (const StringName &constant_name : constant_names) { Dictionary d2; d2["name"] = String(constant_name); Variant constant = Variant::get_constant_value(type, constant_name); @@ -417,7 +417,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List method_names; Variant::get_builtin_method_list(type, &method_names); - for (StringName &method_name : method_names) { + for (const StringName &method_name : method_names) { Dictionary d2; d2["name"] = String(method_name); if (Variant::has_builtin_method_return_value(type, method_name)) { @@ -499,7 +499,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { class_list.sort_custom(); - for (StringName &class_name : class_list) { + for (const StringName &class_name : class_list) { Dictionary d; d["name"] = String(class_name); d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted"); @@ -520,7 +520,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array constants; List constant_list; ClassDB::get_integer_constant_list(class_name, &constant_list, true); - for (String &F : constant_list) { + for (const String &F : constant_list) { StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F); if (enum_name != StringName()) { continue; //enums will be handled on their own @@ -542,7 +542,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array enums; List enum_list; ClassDB::get_enum_list(class_name, &enum_list, true); - for (StringName &F : enum_list) { + for (const StringName &F : enum_list) { Dictionary d2; d2["name"] = String(F); @@ -570,7 +570,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array methods; List method_list; ClassDB::get_method_list(class_name, &method_list, true); - for (MethodInfo &F : method_list) { + for (const MethodInfo &F : method_list) { StringName method_name = F.name; if (F.flags & METHOD_FLAG_VIRTUAL) { //virtual method @@ -687,7 +687,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array signals; List signal_list; ClassDB::get_signal_list(class_name, &signal_list, true); - for (MethodInfo &F : signal_list) { + for (const MethodInfo &F : signal_list) { StringName signal_name = F.name; Dictionary d2; d2["name"] = String(signal_name); @@ -723,7 +723,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array properties; List property_list; ClassDB::get_property_list(class_name, &property_list, true); - for (PropertyInfo &F : property_list) { + for (const PropertyInfo &F : property_list) { if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) { continue; //not real properties } @@ -766,7 +766,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List singleton_list; Engine::get_singleton()->get_singletons(&singleton_list); - for (Engine::Singleton &s : singleton_list) { + for (const Engine::Singleton &s : singleton_list) { Dictionary d; d["name"] = s.name; if (s.class_name != StringName()) { diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 5f91e611025..16bc28e0a2a 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -351,7 +351,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or String library_path; - for (String &E : libraries) { + for (const String &E : libraries) { Vector tags = E.split("."); bool all_tags_met = true; for (int i = 0; i < tags.size(); i++) { diff --git a/core/input/input.cpp b/core/input/input.cpp index e30e7c814fd..c205726b0af 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -174,7 +174,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (PropertyInfo &pi : pinfo) { + for (const PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 0c8705b2630..6714705bb55 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -65,7 +65,7 @@ String InputMap::_suggest_actions(const StringName &p_action) const { float closest_similarity = 0.0; // Find the most action with the most similar name. - for (StringName &action : actions) { + for (const StringName &action : actions) { const float similarity = String(action).similarity(p_action); if (similarity > closest_similarity) { @@ -261,7 +261,7 @@ void InputMap::load_from_project_settings() { List pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (PropertyInfo &pi : pinfo) { + for (const PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index e30a8dfdd0c..8234adea060 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -93,7 +93,7 @@ static Error _erase_recursive(DirAccess *da) { da->list_dir_end(); - for (String &E : dirs) { + for (const String &E : dirs) { Error err = da->change_dir(E); if (err == OK) { err = _erase_recursive(da); @@ -114,7 +114,7 @@ static Error _erase_recursive(DirAccess *da) { } } - for (String &E : files) { + for (const String &E : files) { Error err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; @@ -362,7 +362,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag list_dir_end(); - for (String &rel_path : dirs) { + for (const String &rel_path : dirs) { String target_dir = p_to + rel_path; if (!p_target_da->dir_exists(target_dir)) { Error err = p_target_da->make_dir(target_dir); diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index b0bd328d216..b9fc416f65d 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -35,7 +35,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { List extensions; get_recognized_extensions(&extensions); - for (String &E : extensions) { + for (const String &E : extensions) { if (E.nocasecmp_to(p_extension) == 0) { return true; } diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 132c69b7daf..cd1b6d19944 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -252,7 +252,7 @@ Array IP::_get_local_addresses() const { Array addresses; List ip_addresses; get_local_addresses(&ip_addresses); - for (IPAddress &E : ip_addresses) { + for (const IPAddress &E : ip_addresses) { addresses.push_back(E); } diff --git a/core/io/json.cpp b/core/io/json.cpp index 0381b78172e..5823afbdcd9 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -122,7 +122,7 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_ } bool first_key = true; - for (Variant &E : keys) { + for (const Variant &E : keys) { if (first_key) { first_key = false; } else { diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 34d37dc99bd..4a1d3e52121 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1358,7 +1358,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo obj->get_property_list(&props); int pc = 0; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -1372,7 +1372,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -1418,7 +1418,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo List keys; d.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { /* CharString utf8 = E->->utf8(); diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index ee49335f553..80610e12cb7 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -917,7 +917,7 @@ void MultiplayerAPI::_del_peer(int p_id) { // Some refactoring is needed to make this faster and do paths GC. List keys; path_send_cache.get_key_list(&keys); - for (NodePath &E : keys) { + for (const NodePath &E : keys) { PathSentCache *psc = path_send_cache.getptr(E); psc->confirmed_peers.erase(p_id); } diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index ec43ea9311d..4a76f0191d8 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -268,7 +268,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpd d.get_key_list(&keys); List sortk; - for (Variant &key : keys) { + for (const Variant &key : keys) { DictKey dk; dk.hash = key.hash(); dk.key = key; @@ -278,7 +278,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpd sortk.sort(); int idx = 0; - for (DictKey &E : sortk) { + for (const DictKey &E : sortk) { encode_uint32(E.hash, &tmpdata.write[pos + 8 + idx * 12 + 0]); uint32_t ofs = _pack(E.key, tmpdata, string_cache); encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 4]); diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 695988bd71f..727611a5735 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -165,7 +165,7 @@ Error Resource::copy_from(const Ref &p_resource) { List pi; p_resource->get_property_list(&pi); - for (PropertyInfo &E : pi) { + for (const PropertyInfo &E : pi) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -201,7 +201,7 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Maplocal_scene = p_for_scene; - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -233,7 +233,7 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map, R local_scene = p_for_scene; - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -259,7 +259,7 @@ Ref Resource::duplicate(bool p_subresources) const { Ref r = (Resource *)ClassDB::instantiate(get_class()); ERR_FAIL_COND_V(r.is_null(), Ref()); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -317,7 +317,7 @@ uint32_t Resource::hash_edited_version() const { List plist; get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (E.usage & PROPERTY_USAGE_STORAGE && E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { RES res = get(E.name); if (res.is_valid()) { diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 81ba5cc68d8..5cdb4d74a77 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1054,7 +1054,7 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String extensions.sort(); - for (String &E : extensions) { + for (const String &E : extensions) { String ext = E.to_lower(); p_extensions->push_back(ext); } @@ -1065,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List *p_exten ClassDB::get_resource_base_extensions(&extensions); extensions.sort(); - for (String &E : extensions) { + for (const String &E : extensions) { String ext = E.to_lower(); p_extensions->push_back(ext); } @@ -1603,7 +1603,7 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia List keys; d.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { /* if (!_check_type(dict[E])) continue; @@ -1760,7 +1760,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant res->get_property_list(&property_list); - for (PropertyInfo &E : property_list) { + for (const PropertyInfo &E : property_list) { if (E.usage & PROPERTY_USAGE_STORAGE) { Variant value = res->get(E.name); if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { @@ -1798,7 +1798,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant Dictionary d = p_variant; List keys; d.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { _find_resources(E); Variant v = d[E]; _find_resources(v); @@ -1909,14 +1909,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p List resources; { - for (RES &E : saved_resources) { + for (const RES &E : saved_resources) { ResourceData &rd = resources.push_back(ResourceData())->get(); rd.type = E->get_class(); List property_list; E->get_property_list(&property_list); - for (PropertyInfo &F : property_list) { + for (const PropertyInfo &F : property_list) { if (skip_editor && F.name.begins_with("__editor")) { continue; } @@ -2024,15 +2024,14 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector ofs_table; //now actually save the resources - for (ResourceData &rd : resources) { + for (const ResourceData &rd : resources) { ofs_table.push_back(f->get_position()); save_unicode_string(f, rd.type); f->store_32(rd.properties.size()); - for (Property &F : rd.properties) { - Property &p = F; + for (const Property &p : rd.properties) { f->store_32(p.name_idx); - write_variant(f, p.value, resource_map, external_resources, string_map, F.pi); + write_variant(f, p.value, resource_map, external_resources, string_map, p.pi); } } diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index e7c0176e5a8..1e166015b06 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -148,7 +148,7 @@ void ResourceFormatImporter::get_recognized_extensions(List *p_extension for (int i = 0; i < importers.size(); i++) { List local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (String &F : local_exts) { + for (const String &F : local_exts) { if (!found.has(F)) { p_extensions->push_back(F); found.insert(F); @@ -177,7 +177,7 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ List local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (String &F : local_exts) { + for (const String &F : local_exts) { if (!found.has(F)) { p_extensions->push_back(F); found.insert(F); @@ -385,7 +385,7 @@ void ResourceFormatImporter::get_importers_for_extension(const String &p_extensi for (int i = 0; i < importers.size(); i++) { List local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (String &F : local_exts) { + for (const String &F : local_exts) { if (p_extension.to_lower() == F) { r_importers->push_back(importers[i]); } @@ -406,7 +406,7 @@ Ref ResourceFormatImporter::get_importer_by_extension(const St for (int i = 0; i < importers.size(); i++) { List local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (String &F : local_exts) { + for (const String &F : local_exts) { if (p_extension.to_lower() == F && importers[i]->get_priority() > priority) { importer = importers[i]; priority = importers[i]->get_priority(); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 7e69b2ecab3..d02d8274436 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -58,7 +58,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ get_recognized_extensions_for_type(p_for_type, &extensions); } - for (String &E : extensions) { + for (const String &E : extensions) { if (E.nocasecmp_to(extension) == 0) { return true; } @@ -937,7 +937,7 @@ void ResourceLoader::load_translation_remaps() { Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps"); List keys; remaps.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { Array langs = remaps[E]; Vector lang_remaps; lang_remaps.resize(langs.size()); @@ -1030,7 +1030,7 @@ void ResourceLoader::add_custom_loaders() { List global_classes; ScriptServer::get_global_class_list(&global_classes); - for (StringName &class_name : global_classes) { + for (const StringName &class_name : global_classes) { StringName base_class = ScriptServer::get_global_class_native_base(class_name); if (base_class == custom_loader_base_class) { diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 6158f421d1e..564de5ee691 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -95,7 +95,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t bool recognized = false; saver[i]->get_recognized_extensions(p_resource, &extensions); - for (String &E : extensions) { + for (const String &E : extensions) { if (E.nocasecmp_to(extension) == 0) { recognized = true; } @@ -237,7 +237,7 @@ void ResourceSaver::add_custom_savers() { List global_classes; ScriptServer::get_global_class_list(&global_classes); - for (StringName &class_name : global_classes) { + for (const StringName &class_name : global_classes) { StringName base_class = ScriptServer::get_global_class_native_base(class_name); if (base_class == custom_saver_base_class) { diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 9b506269eae..0960fe19a63 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -336,7 +336,7 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ Map ret_edges; List ret_faces; - for (Face &E : faces) { + for (const Face &E : faces) { Geometry3D::MeshData::Face f; f.plane = E.plane; @@ -439,7 +439,7 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ r_mesh.faces.resize(ret_faces.size()); int idx = 0; - for (Geometry3D::MeshData::Face &E : ret_faces) { + for (const Geometry3D::MeshData::Face &E : ret_faces) { r_mesh.faces.write[idx++] = E; } r_mesh.edges.resize(ret_edges.size()); diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 57495a4fbd3..c6ba39be948 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -359,7 +359,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { ClassInfo *t = classes.getptr(E); ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E) + "'."); if (t->api != p_api || !t->exposed) { @@ -388,7 +388,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (StringName &F : snames) { + for (const StringName &F : snames) { MethodBind *mb = t->method_map[F]; hash = hash_djb2_one_64(mb->get_name().hash(), hash); hash = hash_djb2_one_64(mb->get_argument_count(), hash); @@ -426,7 +426,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (StringName &F : snames) { + for (const StringName &F : snames) { hash = hash_djb2_one_64(F.hash(), hash); hash = hash_djb2_one_64(t->constant_map[F], hash); } @@ -444,7 +444,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (StringName &F : snames) { + for (const StringName &F : snames) { MethodInfo &mi = t->signal_map[F]; hash = hash_djb2_one_64(F.hash(), hash); for (int i = 0; i < mi.arguments.size(); i++) { @@ -465,7 +465,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (StringName &F : snames) { + for (const StringName &F : snames) { PropertySetGet *psg = t->property_setget.getptr(F); ERR_FAIL_COND_V(!psg, 0); @@ -476,7 +476,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { } //property list - for (PropertyInfo &F : t->property_list) { + for (const PropertyInfo &F : t->property_list) { hash = hash_djb2_one_64(F.name.hash(), hash); hash = hash_djb2_one_64(F.type, hash); hash = hash_djb2_one_64(F.hint, hash); @@ -619,11 +619,11 @@ void ClassDB::get_method_list(const StringName &p_class, List *p_met #ifdef DEBUG_METHODS_ENABLED - for (MethodInfo &E : type->virtual_methods) { + for (const MethodInfo &E : type->virtual_methods) { p_methods->push_back(E); } - for (StringName &E : type->method_order) { + for (const StringName &E : type->method_order) { if (p_exclude_from_properties && type->methods_in_properties.has(E)) { continue; } @@ -763,7 +763,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List while (type) { #ifdef DEBUG_METHODS_ENABLED - for (StringName &E : type->constant_order) { + for (const StringName &E : type->constant_order) { p_constants->push_back(E); } #else @@ -1073,10 +1073,12 @@ void ClassDB::get_property_list(const StringName &p_class, List *p ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (PropertyInfo pi : check->property_list) { + for (const PropertyInfo &pi : check->property_list) { if (p_validator) { - p_validator->_validate_property(pi); - p_list->push_back(pi); + // Making a copy as we may modify it. + PropertyInfo pi_mut = pi; + p_validator->_validate_property(pi_mut); + p_list->push_back(pi_mut); } else { p_list->push_back(pi); } @@ -1428,7 +1430,7 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List *p ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (MethodInfo &E : check->virtual_methods) { + for (const MethodInfo &E : check->virtual_methods) { p_methods->push_back(E); } @@ -1533,7 +1535,7 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con if (c) { List plist; c->get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) { if (!default_values[p_class].has(E.name)) { Variant v = c->get(E.name); diff --git a/core/object/object.cpp b/core/object/object.cpp index 0e397d85186..d552d5e5e0c 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -969,7 +969,7 @@ Vector Object::_get_meta_list_bind() const { List keys; metadata.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { _metaret.push_back(E); } @@ -979,7 +979,7 @@ Vector Object::_get_meta_list_bind() const { void Object::get_meta_list(List *p_list) const { List keys; metadata.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { p_list->push_back(E); } } @@ -1184,7 +1184,7 @@ Array Object::_get_signal_list() const { get_signal_list(&signal_list); Array ret; - for (MethodInfo &E : signal_list) { + for (const MethodInfo &E : signal_list) { ret.push_back(Dictionary(E)); } @@ -1197,7 +1197,7 @@ Array Object::_get_signal_connection_list(const String &p_signal) const { Array ret; - for (Connection &c : conns) { + for (const Connection &c : conns) { if (c.signal.get_name() == p_signal) { ret.push_back(c); } @@ -1499,7 +1499,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { List keys; d.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { _clear_internal_resource_paths(E); _clear_internal_resource_paths(d[E]); } @@ -1530,7 +1530,7 @@ void Object::clear_internal_resource_paths() { get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { _clear_internal_resource_paths(get(E.name)); } } @@ -1665,7 +1665,7 @@ void Object::get_translatable_strings(List *p_strings) const { List plist; get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) { continue; } diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 5aa032192e7..0fb8c7350cb 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -63,7 +63,7 @@ Array Script::_get_script_property_list() { Array ret; List list; get_script_property_list(&list); - for (PropertyInfo &E : list) { + for (const PropertyInfo &E : list) { ret.append(E.operator Dictionary()); } return ret; @@ -73,7 +73,7 @@ Array Script::_get_script_method_list() { Array ret; List list; get_script_method_list(&list); - for (MethodInfo &E : list) { + for (const MethodInfo &E : list) { ret.append(E.operator Dictionary()); } return ret; @@ -83,7 +83,7 @@ Array Script::_get_script_signal_list() { Array ret; List list; get_script_signal_list(&list); - for (MethodInfo &E : list) { + for (const MethodInfo &E : list) { ret.append(E.operator Dictionary()); } return ret; @@ -257,7 +257,7 @@ void ScriptServer::get_global_class_list(List *r_global_classes) { classes.push_back(*K); } classes.sort_custom(); - for (StringName &E : classes) { + for (const StringName &E : classes) { r_global_classes->push_back(E); } } @@ -266,7 +266,7 @@ void ScriptServer::save_global_classes() { List gc; get_global_class_list(&gc); Array gcarr; - for (StringName &E : gc) { + for (const StringName &E : gc) { Dictionary d; d["class"] = E; d["language"] = global_classes[E].language; @@ -297,7 +297,7 @@ void ScriptServer::save_global_classes() { void ScriptInstance::get_property_state(List> &state) { List pinfo; get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.usage & PROPERTY_USAGE_STORAGE) { Pair p; p.first = E.name; diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index cf0b8d10dbc..5863bd1c46d 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -66,7 +66,7 @@ void OptimizedTranslation::generate(const Ref &p_from) { int total_compression_size = 0; int total_string_size = 0; - for (StringName &E : keys) { + for (const StringName &E : keys) { //hash string CharString cs = E.operator String().utf8(); uint32_t h = hash(0, cs.get_data()); diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 981954c8aee..19d23fd3751 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -841,7 +841,7 @@ Vector Translation::_get_message_list() const { void Translation::_set_messages(const Dictionary &p_messages) { List keys; p_messages.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { translation_map[E] = p_messages[E]; } } diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index afd3b765884..1da00aa54b4 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -47,7 +47,7 @@ void TranslationPO::print_translation_map() { List context_l; translation_map.get_key_list(&context_l); - for (StringName &ctx : context_l) { + for (const StringName &ctx : context_l) { file->store_line(" ===== Context: " + String::utf8(String(ctx).utf8()) + " ===== "); const HashMap> &inner_map = translation_map[ctx]; @@ -73,7 +73,7 @@ Dictionary TranslationPO::_get_messages() const { List context_l; translation_map.get_key_list(&context_l); - for (StringName &ctx : context_l) { + for (const StringName &ctx : context_l) { const HashMap> &id_str_map = translation_map[ctx]; Dictionary d2; @@ -96,7 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) { List context_l; p_messages.get_key_list(&context_l); - for (Variant &ctx : context_l) { + for (const Variant &ctx : context_l) { const Dictionary &id_str_map = p_messages[ctx]; HashMap> temp_map; @@ -118,7 +118,7 @@ Vector TranslationPO::_get_message_list() const { get_message_list(&msgs); Vector v; - for (StringName &E : msgs) { + for (const StringName &E : msgs) { v.push_back(E); } @@ -278,7 +278,7 @@ void TranslationPO::get_message_list(List *r_messages) const { List context_l; translation_map.get_key_list(&context_l); - for (StringName &E : context_l) { + for (const StringName &E : context_l) { if (String(E) != "") { continue; } @@ -297,7 +297,7 @@ int TranslationPO::get_message_count() const { translation_map.get_key_list(&context_l); int count = 0; - for (StringName &E : context_l) { + for (const StringName &E : context_l) { count += translation_map[E].size(); } return count; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index dbb8dc8283e..7beecdb6b57 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3421,7 +3421,7 @@ String String::format(const Variant &values, String placeholder) const { List keys; d.get_key_list(&keys); - for (Variant &key : keys) { + for (const Variant &key : keys) { new_string = new_string.replace(placeholder.replace("_", key), d[key]); } } else { diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index 2a3a9a4f1a1..f487e718f4c 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -407,7 +407,7 @@ Array Signal::get_connections() const { object->get_signal_connection_list(name, &connections); Array arr; - for (Object::Connection &E : connections) { + for (const Object::Connection &E : connections) { arr.push_back(E); } return arr; diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 12b64650059..97a1b4c02a8 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1681,7 +1681,7 @@ String Variant::stringify(List &stack) const { Vector<_VariantStrPair> pairs; - for (Variant &E : keys) { + for (const Variant &E : keys) { _VariantStrPair sp; sp.key = E.stringify(stack); sp.value = d[E].stringify(stack); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index a9645da0453..f8538f71d37 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1124,7 +1124,7 @@ bool Variant::has_builtin_method_return_value(Variant::Type p_type, const String void Variant::get_builtin_method_list(Variant::Type p_type, List *p_list) { ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX); - for (StringName &E : builtin_method_names[p_type]) { + for (const StringName &E : builtin_method_names[p_type]) { p_list->push_back(E); } } @@ -1188,7 +1188,7 @@ void Variant::get_method_list(List *p_list) const { obj->get_method_list(p_list); } } else { - for (StringName &E : builtin_method_names[type]) { + for (const StringName &E : builtin_method_names[type]) { const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E); ERR_CONTINUE(!method); diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index dc92ac8ac43..50c48fd386c 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1586,7 +1586,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str List props; obj->get_property_list(&props); bool first = true; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (E.usage & PROPERTY_USAGE_STORAGE || E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { //must be serialized diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 62228ea87c9..ae3c7685fd7 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -1093,7 +1093,7 @@ void Variant::get_property_list(List *p_list) const { const Dictionary *dic = reinterpret_cast(_data._mem); List keys; dic->get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { if (E.get_type() == Variant::STRING) { p_list->push_back(PropertyInfo(Variant::STRING, E)); } @@ -1106,7 +1106,7 @@ void Variant::get_property_list(List *p_list) const { } else { List members; get_member_list(type, &members); - for (StringName &E : members) { + for (const StringName &E : members) { PropertyInfo pi; pi.name = E; pi.type = get_member_type(type, E); diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index e9fa952af3e..64f07e075e5 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -1397,7 +1397,7 @@ uint32_t Variant::get_utility_function_hash(const StringName &p_name) { } void Variant::get_utility_function_list(List *r_functions) { - for (StringName &E : utility_function_name_table) { + for (const StringName &E : utility_function_name_table) { r_functions->push_back(E); } } diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 4c33feb52c7..e01c6a0e0f3 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -269,7 +269,7 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, Str break; // IPv6 uses index. } - for (IPAddress &F : c.ip_addresses) { + for (const IPAddress &F : c.ip_addresses) { if (!F.is_ipv4()) { continue; // Wrong IP type } diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 48e4be498bf..f0a1531f700 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -8542,7 +8542,7 @@ void RenderingDeviceVulkan::_free_rids(T &p_owner, const char *p_type) { } else { WARN_PRINT(vformat("%d RIDs of type \"%s\" were leaked.", owned.size(), p_type)); } - for (RID E : owned) { + for (const RID &E : owned) { free(E); } } @@ -8769,7 +8769,7 @@ void RenderingDeviceVulkan::finalize() { E = N; } //free non shared second, this will avoid an error trying to free unexisting textures due to dependencies. - for (RID E : owned) { + for (const RID &E : owned) { free(E); } } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 0b4f4964c15..1e3140e2028 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -898,7 +898,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref &p_event) { } // 6-(undo) reinsert overlapped keys - for (AnimMoveRestore &amr : to_restore) { + for (const AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } @@ -1090,7 +1090,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { //reselect duplicated selection.clear(); - for (Pair &E : new_selection_values) { + for (const Pair &E : new_selection_values) { int track = E.first; float time = E.second; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 2adfc29f741..91835c1866b 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -598,7 +598,7 @@ public: if (ap) { List anims; ap->get_animation_list(&anims); - for (StringName &E : anims) { + for (const StringName &E : anims) { if (animations != String()) { animations += ","; } @@ -3356,7 +3356,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_frame = Engine::get_singleton()->get_frames_drawn(); - for (InsertData &E : insert_data) { + for (const InsertData &E : insert_data) { //prevent insertion of multiple tracks if (E.path == p_id.path) { return; //already inserted a track for this on this frame @@ -3843,7 +3843,7 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b List pinfo; property_info_base.get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.name == leftover_path[leftover_path.size() - 1]) { return E; } @@ -4675,7 +4675,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { List minfo; base->get_method_list(&minfo); - for (MethodInfo &E : minfo) { + for (const MethodInfo &E : minfo) { if (E.name == p_method) { Dictionary d; d["method"] = p_method; @@ -5150,7 +5150,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map new_selection; - for (Pair &E : new_selection_values) { + for (const Pair &E : new_selection_values) { int track = E.first; float time = E.second; @@ -5541,7 +5541,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (cleanup_all->is_pressed()) { List names; AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E)); } } else { diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 012276fe10c..03695419cbf 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -854,7 +854,7 @@ void CodeTextEditor::_complete_request() { return; } - for (ScriptCodeCompletionOption &e : entries) { + for (const ScriptCodeCompletionOption &e : entries) { Color font_color = completion_font_color; if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) { font_color = completion_string_color; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index f5cfe0fe57b..c773f51342e 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -1023,7 +1023,7 @@ void ConnectionsDock::update_tree() { List connections; selectedNode->get_signal_connection_list(signal_name, &connections); - for (Object::Connection &F : connections) { + for (const Object::Connection &F : connections) { Connection cn = F; if (!(cn.flags & CONNECT_PERSIST)) { continue; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index abe17bf4276..3389b533173 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -447,7 +447,7 @@ Variant CreateDialog::instance_selected() { List pinfo; ((Object *)obj)->get_property_list(&pinfo); - for (PropertyInfo &pi : pinfo) { + for (const PropertyInfo &pi : pinfo) { if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) { Object *prop = ClassDB::instantiate(pi.class_name); ((Object *)obj)->set(pi.name, prop); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 8af59a62de4..9856fbec74e 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -347,7 +347,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da uint64_t total = 0; - for (DebuggerMarshalls::ResourceInfo &E : usage.infos) { + for (const DebuggerMarshalls::ResourceInfo &E : usage.infos) { TreeItem *it = vmem_tree->create_item(root); String type = E.type; int bytes = E.vram; diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 3306fc3b44d..069ae2c7f25 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -55,7 +55,7 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { search->clear_filters(); List ext; ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext); - for (String &E : ext) { + for (const String &E : ext) { search->add_filter("*" + E); } search->popup_file_dialog(); @@ -120,7 +120,7 @@ void DependencyEditor::_fix_all() { Map> candidates; - for (String &E : missing) { + for (const String &E : missing) { String base = E.get_file(); if (!candidates.has(base)) { candidates[base] = Map(); @@ -166,7 +166,7 @@ void DependencyEditor::_update_list() { bool broken = false; - for (String &n : deps) { + for (const String &n : deps) { TreeItem *item = tree->create_item(root); String path; String type; @@ -748,7 +748,7 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List &path void OrphanResourcesDialog::_delete_confirm() { DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (String &E : paths) { + for (const String &E : paths) { da->remove(E); EditorFileSystem::get_singleton()->update_file(E); } diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 9258ff8043f..cbd4a1b9160 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -266,7 +266,7 @@ void DocTools::generate(bool p_basic_types) { } List::Element *EO = own_properties.front(); - for (PropertyInfo &E : properties) { + for (const PropertyInfo &E : properties) { bool inherited = EO == nullptr; if (EO && EO->get() == E) { inherited = false; @@ -367,7 +367,7 @@ void DocTools::generate(bool p_basic_types) { ClassDB::get_method_list(name, &method_list, true); method_list.sort(); - for (MethodInfo &E : method_list) { + for (const MethodInfo &E : method_list) { if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } @@ -455,7 +455,7 @@ void DocTools::generate(bool p_basic_types) { List constant_list; ClassDB::get_integer_constant_list(name, &constant_list, true); - for (String &E : constant_list) { + for (const String &E : constant_list) { DocData::ConstantDoc constant; constant.name = E; constant.value = itos(ClassDB::get_integer_constant(name, E)); @@ -469,7 +469,7 @@ void DocTools::generate(bool p_basic_types) { { List l; Theme::get_default()->get_constant_list(cname, &l); - for (StringName &E : l) { + for (const StringName &E : l) { DocData::PropertyDoc pd; pd.name = E; pd.type = "int"; @@ -479,7 +479,7 @@ void DocTools::generate(bool p_basic_types) { l.clear(); Theme::get_default()->get_color_list(cname, &l); - for (StringName &E : l) { + for (const StringName &E : l) { DocData::PropertyDoc pd; pd.name = E; pd.type = "Color"; @@ -489,7 +489,7 @@ void DocTools::generate(bool p_basic_types) { l.clear(); Theme::get_default()->get_icon_list(cname, &l); - for (StringName &E : l) { + for (const StringName &E : l) { DocData::PropertyDoc pd; pd.name = E; pd.type = "Texture2D"; @@ -497,7 +497,7 @@ void DocTools::generate(bool p_basic_types) { } l.clear(); Theme::get_default()->get_font_list(cname, &l); - for (StringName &E : l) { + for (const StringName &E : l) { DocData::PropertyDoc pd; pd.name = E; pd.type = "Font"; @@ -505,7 +505,7 @@ void DocTools::generate(bool p_basic_types) { } l.clear(); Theme::get_default()->get_font_size_list(cname, &l); - for (StringName &E : l) { + for (const StringName &E : l) { DocData::PropertyDoc pd; pd.name = E; pd.type = "int"; @@ -513,7 +513,7 @@ void DocTools::generate(bool p_basic_types) { } l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); - for (StringName &E : l) { + for (const StringName &E : l) { DocData::PropertyDoc pd; pd.name = E; pd.type = "StyleBox"; @@ -621,7 +621,7 @@ void DocTools::generate(bool p_basic_types) { method_list.push_back(mi); } - for (MethodInfo &mi : method_list) { + for (const MethodInfo &mi : method_list) { DocData::MethodDoc method; method.name = mi.name; @@ -674,7 +674,7 @@ void DocTools::generate(bool p_basic_types) { List properties; v.get_property_list(&properties); - for (PropertyInfo &pi : properties) { + for (const PropertyInfo &pi : properties) { DocData::PropertyDoc property; property.name = pi.name; property.type = Variant::get_type_name(pi.type); @@ -686,7 +686,7 @@ void DocTools::generate(bool p_basic_types) { List constants; Variant::get_constants_for_type(Variant::Type(i), &constants); - for (StringName &E : constants) { + for (const StringName &E : constants) { DocData::ConstantDoc constant; constant.name = E; Variant value = Variant::get_constant_value(Variant::Type(i), E); @@ -721,7 +721,7 @@ void DocTools::generate(bool p_basic_types) { Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (Engine::Singleton &s : singletons) { + for (const Engine::Singleton &s : singletons) { DocData::PropertyDoc pd; if (!s.ptr) { continue; @@ -740,7 +740,7 @@ void DocTools::generate(bool p_basic_types) { List utility_functions; Variant::get_utility_function_list(&utility_functions); utility_functions.sort_custom(); - for (StringName &E : utility_functions) { + for (const StringName &E : utility_functions) { DocData::MethodDoc md; md.name = E; //return @@ -790,7 +790,7 @@ void DocTools::generate(bool p_basic_types) { List minfo; lang->get_public_functions(&minfo); - for (MethodInfo &mi : minfo) { + for (const MethodInfo &mi : minfo) { DocData::MethodDoc md; md.name = mi.name; @@ -823,7 +823,7 @@ void DocTools::generate(bool p_basic_types) { List> cinfo; lang->get_public_constants(&cinfo); - for (Pair &E : cinfo) { + for (const Pair &E : cinfo) { DocData::ConstantDoc cd; cd.name = E.first; cd.value = E.second; diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 5a85c8b31b6..4a19f007d44 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -920,7 +920,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { List effects; ClassDB::get_inheriters_from_class("AudioEffect", &effects); effects.sort_custom(); - for (StringName &E : effects) { + for (const StringName &E : effects) { if (!ClassDB::can_instantiate(E)) { continue; } @@ -1331,7 +1331,7 @@ EditorAudioBuses::EditorAudioBuses() { file_dialog = memnew(EditorFileDialog); List ext; ResourceLoader::get_recognized_extensions_for_type("AudioBusLayout", &ext); - for (String &E : ext) { + for (const String &E : ext) { file_dialog->add_filter("*." + E + "; Audio Bus Layout"); } add_child(file_dialog); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index e81f788290f..fad76682b5e 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -46,11 +46,11 @@ void EditorAutoloadSettings::_notification(int p_what) { ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); - for (String &E : afn) { + for (const String &E : afn) { file_dialog->add_filter("*." + E); } - for (AutoLoadInfo &info : autoload_cache) { + for (const AutoLoadInfo &info : autoload_cache) { if (info.node && info.in_editor) { get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } @@ -101,7 +101,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin for (int i = 0; i < ScriptServer::get_language_count(); i++) { List keywords; ScriptServer::get_language(i)->get_reserved_words(&keywords); - for (String &E : keywords) { + for (const String &E : keywords) { if (E == p_name) { if (r_error) { *r_error = TTR("Invalid name.") + "\n" + TTR("Keyword cannot be used as an autoload name."); @@ -378,7 +378,7 @@ void EditorAutoloadSettings::update_autoload() { Map to_remove; List to_add; - for (AutoLoadInfo &info : autoload_cache) { + for (const AutoLoadInfo &info : autoload_cache) { to_remove.insert(info.name, info); } @@ -390,7 +390,7 @@ void EditorAutoloadSettings::update_autoload() { List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (PropertyInfo &pi : props) { + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -643,7 +643,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int i = 0; - for (AutoLoadInfo &F : autoload_cache) { + for (const AutoLoadInfo &F : autoload_cache) { orders.write[i++] = F.order; } @@ -655,7 +655,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & i = 0; - for (AutoLoadInfo &F : autoload_cache) { + for (const AutoLoadInfo &F : autoload_cache) { undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, orders[i++]); undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, F.order); } @@ -758,7 +758,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { // Make first cache List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (PropertyInfo &pi : props) { + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -894,7 +894,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } EditorAutoloadSettings::~EditorAutoloadSettings() { - for (AutoLoadInfo &info : autoload_cache) { + for (const AutoLoadInfo &info : autoload_cache) { if (info.node && !info.in_editor) { memdelete(info.node); } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 9204974d1aa..c62e5b75b28 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -299,7 +299,7 @@ void EditorData::copy_object_params(Object *p_object) { List pinfo; p_object->get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (!(E.usage & PROPERTY_USAGE_EDITOR) || E.name == "script" || E.name == "scripts") { continue; } @@ -404,7 +404,7 @@ void EditorData::restore_editor_global_states() { void EditorData::paste_object_params(Object *p_object) { ERR_FAIL_NULL(p_object); undo_redo.create_action(TTR("Paste Params")); - for (PropertyData &E : clipboard) { + for (const PropertyData &E : clipboard) { String name = E.name; undo_redo.add_do_property(p_object, name, E.value); undo_redo.add_undo_property(p_object, name, p_object->get(name)); @@ -616,7 +616,7 @@ bool EditorData::check_and_update_scene(int p_idx) { //transfer selection List new_selection; - for (Node *E : edited_scene.write[p_idx].selection) { + for (const Node *E : edited_scene.write[p_idx].selection) { NodePath p = edited_scene[p_idx].root->get_path_to(E); Node *new_node = new_scene->get_node(p); if (new_node) { @@ -964,7 +964,7 @@ void EditorData::script_class_save_icon_paths() { _script_class_icon_paths.get_key_list(&keys); Dictionary d; - for (StringName &E : keys) { + for (const StringName &E : keys) { if (ScriptServer::is_global_class(E)) { d[E] = _script_class_icon_paths[E]; } @@ -996,7 +996,7 @@ void EditorData::script_class_load_icon_paths() { List keys; d.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { String name = E.operator String(); _script_class_icon_paths[name] = d[name]; @@ -1076,7 +1076,7 @@ bool EditorSelection::is_selected(Node *p_node) const { Array EditorSelection::_get_transformable_selected_nodes() { Array ret; - for (Node *E : selected_node_list) { + for (const Node *E : selected_node_list) { ret.push_back(E); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index bec63fc0783..b374f56f6d7 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -436,7 +436,7 @@ Ref EditorExportPlatform::create_preset() { List options; get_export_options(&options); - for (ExportOption &E : options) { + for (const ExportOption &E : options) { preset->properties.push_back(E.option); preset->values[E.option.name] = E.default_value; } @@ -679,7 +679,7 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai platform->get_preset_features(p_preset, &feature_list); FeatureContainers result; - for (String &E : feature_list) { + for (const String &E : feature_list) { result.features.insert(E); result.features_pv.push_back(E); } @@ -752,7 +752,7 @@ Error EditorExportPlatform::export_project_files(const Ref & List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (PropertyInfo &pi : props) { + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -897,7 +897,7 @@ Error EditorExportPlatform::export_project_files(const Ref & Set remap_features; - for (String &F : remaps) { + for (const String &F : remaps) { String remap = F; String feature = remap.get_slice(".", 1); if (features.has(feature)) { @@ -911,7 +911,7 @@ Error EditorExportPlatform::export_project_files(const Ref & err = OK; - for (String &F : remaps) { + for (const String &F : remaps) { String remap = F; if (remap == "path") { String remapped_path = config->get_value("remap", remap); @@ -1647,7 +1647,7 @@ void EditorExport::load_config() { config->get_section_keys(option_section, &options); - for (String &E : options) { + for (const String &E : options) { Variant value = config->get_value(option_section, E); preset->set(E, value); @@ -1689,7 +1689,7 @@ void EditorExport::update_export_presets() { preset->properties.clear(); preset->values.clear(); - for (EditorExportPlatform::ExportOption &E : options) { + for (const EditorExportPlatform::ExportOption &E : options) { preset->properties.push_back(E.option); StringName option_name = E.option.name; diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 1bc852000d4..22f44a54bbb 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -527,7 +527,7 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S ClassDB::get_direct_inheriters_from_class(p_class, &child_classes); child_classes.sort_custom(); - for (StringName &name : child_classes) { + for (const StringName &name : child_classes) { if (String(name).begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { continue; } @@ -596,7 +596,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { TreeItem *properties = property_list->create_item(root); properties->set_text(0, TTR("Class Properties:")); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { String name = E.name; if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index f11e8d350d2..5ccbed1b498 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -830,7 +830,7 @@ void EditorFileDialog::update_file_list() { while (!files.is_empty()) { bool match = patterns.is_empty(); - for (String &E : patterns) { + for (const String &E : patterns) { if (files.front()->get().matchn(E)) { match = true; break; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index d290db6431f..4540f75968a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -484,7 +484,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo memdelete(md5s); //imported files are gone, reimport - for (String &E : to_check) { + for (const String &E : to_check) { if (!FileAccess::exists(E)) { return true; } @@ -524,7 +524,7 @@ bool EditorFileSystem::_update_scan_actions() { Vector reimports; Vector reloads; - for (ItemAction &ia : scan_actions) { + for (const ItemAction &ia : scan_actions) { switch (ia.action) { case ItemAction::ACTION_NONE: { } break; @@ -1072,7 +1072,7 @@ void EditorFileSystem::_delete_internal_files(String p_file) { List paths; ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths); DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (String &E : paths) { + for (const String &E : paths) { da->remove(E); } da->remove(p_file + ".import"); @@ -1413,7 +1413,7 @@ Vector EditorFileSystem::_get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); Vector ret; - for (String &E : deps) { + for (const String &E : deps) { ret.push_back(E); } @@ -1609,14 +1609,14 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List options; importer->get_import_options(&options); //set default values - for (ResourceImporter::ImportOption &E : options) { + for (const ResourceImporter::ImportOption &E : options) { source_file_options[p_files[i]][E.option.name] = E.default_value; } if (config->has_section("params")) { List sk; config->get_section_keys("params", &sk); - for (String ¶m : sk) { + for (const String ¶m : sk) { Variant value = config->get_value("params", param); //override with whathever is in file source_file_options[p_files[i]][param] = value; @@ -1690,7 +1690,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List options; importer->get_import_options(&options); //set default values - for (ResourceImporter::ImportOption &F : options) { + for (const ResourceImporter::ImportOption &F : options) { String base = F.option.name; Variant v = F.default_value; if (source_file_options[file].has(base)) { @@ -1773,7 +1773,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Maphas_section("params")) { List sk; cf->get_section_keys("params", &sk); - for (String &E : sk) { + for (const String &E : sk) { params[E] = cf->get_value("params", E); } } @@ -1823,7 +1823,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map opts; importer->get_import_options(&opts); - for (ResourceImporter::ImportOption &E : opts) { + for (const ResourceImporter::ImportOption &E : opts) { if (!params.has(E.option.name)) { //this one is not present params[E.option.name] = E.default_value; } @@ -1835,7 +1835,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map v; d.get_key_list(&v); - for (Variant &E : v) { + for (const Variant &E : v) { params[E] = d[E]; } } @@ -1882,7 +1882,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Mapget_save_extension(); f->store_line("path." + E + "=\"" + path + "\""); @@ -1908,7 +1908,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map sk; config->get_section_keys("params", &sk); - for (String ¶m : sk) { + for (const String ¶m : sk) { //not very clean, but should work String value = config->get_value("params", param); if (value == p_group_file) { @@ -2245,13 +2245,13 @@ void EditorFileSystem::_update_extensions() { List extensionsl; ResourceLoader::get_recognized_extensions_for_type("", &extensionsl); - for (String &E : extensionsl) { + for (const String &E : extensionsl) { valid_extensions.insert(E); } extensionsl.clear(); ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl); - for (String &E : extensionsl) { + for (const String &E : extensionsl) { import_extensions.insert(E); } } diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 7b7cf0bf48d..29e3236ac22 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -109,7 +109,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p List plist; p_node->get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (E.usage & PROPERTY_USAGE_EDITOR) { if (E.type == Variant::OBJECT) { RES res = p_node->get(E.name); @@ -228,7 +228,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set &resources) { Set unfold_group; - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (E.usage & PROPERTY_USAGE_CATEGORY) { group = ""; group_base = ""; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 9a0dd4e3bc4..ff34e2c93d3 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1508,7 +1508,7 @@ String EditorInspector::get_selected_path() const { } void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref ped) { - for (EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { + for (const EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { EditorProperty *ep = Object::cast_to(F.property_editor); current_vbox->add_child(F.property_editor); @@ -1952,7 +1952,7 @@ void EditorInspector::update_tree() { List editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector ped->added_editors.clear(); - for (EditorInspectorPlugin::AddedEditor &F : editors) { + for (const EditorInspectorPlugin::AddedEditor &F : editors) { EditorProperty *ep = Object::cast_to(F.property_editor); if (ep) { @@ -2391,7 +2391,7 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { Variant to_create; List pinfo; object->get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.name == p_path) { Callable::CallError ce; Variant::construct(E.type, to_create, nullptr, 0, ce); diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 1f70c59e660..0c8660c2167 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -92,7 +92,7 @@ void EditorLayoutsDialog::_post_popup() { List layouts; config.ptr()->get_sections(&layouts); - for (String &E : layouts) { + for (const String &E : layouts) { layout_names->add_item(E); } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ce5f762b13e..b80f7231ff1 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -914,7 +914,7 @@ void EditorNode::_resources_reimported(const Vector &p_resources) { } } - for (String &E : scenes) { + for (const String &E : scenes) { reload_scene(E); } @@ -1143,7 +1143,7 @@ void EditorNode::save_resource_as(const Ref &p_resource, const String file->clear_filters(); List 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 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 bool ret_changed = false; List 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 Dictionary d = obj->get(E.name); List 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 &p_resource, Setget_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()) { @@ -1883,7 +1883,7 @@ void EditorNode::_dialog_action(String p_file) { // erase List 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 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 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 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(); @@ -6738,7 +6738,7 @@ EditorNode::EditorNode() { file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List 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); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index c52861a2a2f..f3b3eedccc7 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -40,7 +40,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { List pinfo; p_obj->get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 967f2aa47b8..7d809ea656d 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -221,7 +221,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } Set valid_extensions; - for (String &E : extensions) { + for (const String &E : extensions) { valid_extensions.insert(E); } @@ -260,7 +260,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { List property_list; edited_resource->get_property_list(&property_list); List> propvalues; - for (PropertyInfo &pi : property_list) { + for (const PropertyInfo &pi : property_list) { Pair p; if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; @@ -275,7 +275,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { Ref unique_resource = Ref(Object::cast_to(inst)); ERR_FAIL_COND(unique_resource.is_null()); - for (Pair &p : propvalues) { + for (const Pair &p : propvalues) { unique_resource->set(p.first, p.second); } @@ -465,11 +465,11 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set * List inheriters; ClassDB::get_inheriters_from_class(base, &inheriters); - for (StringName &E : inheriters) { + for (const StringName &E : inheriters) { p_vector->insert(E); } - for (StringName &E : global_classes) { + for (const StringName &E : global_classes) { if (EditorNode::get_editor_data().script_class_is_parent(E, base)) { p_vector->insert(E); } diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index b446f922f64..4fadbf59222 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -228,7 +228,7 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } printf("Running: %s", exec.utf8().get_data()); - for (String &E : args) { + for (const String &E : args) { printf(" %s", E.utf8().get_data()); }; printf("\n"); @@ -267,7 +267,7 @@ void EditorRun::stop_child_process(OS::ProcessID p_pid) { void EditorRun::stop() { if (status != STATUS_STOP && pids.size() > 0) { - for (OS::ProcessID &E : pids) { + for (const OS::ProcessID &E : pids) { OS::get_singleton()->kill(E); } } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index a14ab1d4f83..99549f40d79 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -759,7 +759,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { List keys; p_extra_config->get_section_keys("presets", &keys); - for (String &key : keys) { + for (const String &key : keys) { Variant val = p_extra_config->get_value("presets", key); set(key, val); } @@ -1013,7 +1013,7 @@ void EditorSettings::setup_network() { String selected = "127.0.0.1"; // Check that current remote_host is a valid interface address and populate hints. - for (IPAddress &ip : local_ip) { + for (const IPAddress &ip : local_ip) { // link-local IPv6 addresses don't work, skipping them if (String(ip).begins_with("fe80:0:0:0:")) { // fe80::/64 continue; @@ -1299,7 +1299,7 @@ void EditorSettings::list_text_editor_themes() { memdelete(d); custom_themes.sort(); - for (String &E : custom_themes) { + for (const String &E : custom_themes) { themes += "," + E; } } @@ -1328,7 +1328,7 @@ void EditorSettings::load_text_editor_theme() { List keys; cf->get_section_keys("color_theme", &keys); - for (String &key : keys) { + for (const String &key : keys) { String val = cf->get_value("color_theme", key); // don't load if it's not already there! diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 225eac36a53..dbbbb03864a 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -135,7 +135,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory _sort_file_info_list(file_list); // Build the tree. - for (FileInfo &fi : file_list) { + for (const FileInfo &fi : file_list) { TreeItem *file_item = tree->create_item(subdirectory_item); file_item->set_text(0, fi.name); file_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE); @@ -964,7 +964,7 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit List importer_exts; ResourceImporterScene::get_singleton()->get_recognized_extensions(&importer_exts); String extension = fpath.get_extension(); - for (String &E : importer_exts) { + for (const String &E : importer_exts) { if (extension.nocasecmp_to(E) == 0) { is_imported = true; break; @@ -1413,7 +1413,7 @@ void FileSystemDock::_make_scene_confirm() { ResourceSaver::get_recognized_extensions(sd, &extensions); bool extension_correct = false; - for (String &E : extensions) { + for (const String &E : extensions) { if (E == extension) { extension_correct = true; break; diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index deedbe104cb..113306fc8a0 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -285,7 +285,7 @@ void GroupDialog::_load_groups(Node *p_current) { List gi; p_current->get_groups(&gi); - for (Node::GroupInfo &E : gi) { + for (const Node::GroupInfo &E : gi) { if (!E.persistent) { continue; } @@ -627,7 +627,7 @@ void GroupsEditor::update_tree() { TreeItem *root = tree->create_item(); - for (GroupInfo &gi : groups) { + for (const GroupInfo &gi : groups) { if (!gi.persistent) { continue; } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index d67950ec9e3..e9160f04146 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -312,7 +312,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map anims; ap->get_animation_list(&anims); - for (StringName &E : anims) { + for (const StringName &E : anims) { Ref anim = ap->get_animation(E); ERR_CONTINUE(anim.is_null()); for (int i = 0; i < anim->get_track_count(); i++) { @@ -659,7 +659,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map &E : shapes) { + for (const Ref &E : shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E); base->add_child(cshape); @@ -712,7 +712,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts); - for (ImportOption &E : iopts) { + for (const ImportOption &E : iopts) { if (!node_settings.has(E.option.name)) { node_settings[E.option.name] = E.default_value; } @@ -756,7 +756,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map anims; ap->get_animation_list(&anims); - for (StringName &name : anims) { + for (const StringName &name : anims) { Ref anim = ap->get_animation(name); if (p_animation_data.has(name)) { Dictionary anim_settings = p_animation_data[name]; @@ -764,7 +764,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION, &iopts); - for (ImportOption &F : iopts) { + for (const ImportOption &F : iopts) { if (!anim_settings.has(F.option.name)) { anim_settings[F.option.name] = F.default_value; } @@ -935,7 +935,7 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_ void ResourceImporterScene::_optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle) { List anim_names; anim->get_animation_list(&anim_names); - for (StringName &E : anim_names) { + for (const StringName &E : anim_names) { Ref a = anim->get_animation(E); a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle)); } @@ -1045,7 +1045,7 @@ void ResourceImporterScene::get_import_options(List *r_options, in String script_ext_hint; - for (String &E : script_extentions) { + for (const String &E : script_extentions) { if (script_ext_hint != "") { script_ext_hint += ","; } @@ -1088,7 +1088,7 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte List extensions; E->get()->get_extensions(&extensions); - for (String &F : extensions) { + for (const String &F : extensions) { if (F.to_lower() == ext) { importer = E; break; @@ -1118,7 +1118,7 @@ Ref ResourceImporterScene::import_animation_from_other_importer(Edito List extensions; E->get()->get_extensions(&extensions); - for (String &F : extensions) { + for (const String &F : extensions) { if (F.to_lower() == ext) { importer = E; break; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index ad271eaf045..19a8f209bbc 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -305,7 +305,7 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { if (anim_node) { List animations; anim_node->get_animation_list(&animations); - for (StringName &E : animations) { + for (const StringName &E : animations) { _fill_animation(scene_tree, anim_node->get_animation(E), E, item); } } @@ -394,7 +394,7 @@ void SceneImportSettings::_load_default_subresource_settings(Map options; ResourceImporterScene::get_singleton()->get_internal_import_options(p_category, &options); - for (ResourceImporterScene::ImportOption &E : options) { + for (const ResourceImporterScene::ImportOption &E : options) { String key = E.option.name; if (d.has(key)) { settings[key] = d[key]; @@ -440,7 +440,7 @@ void SceneImportSettings::open_settings(const String &p_path) { if (err == OK) { List keys; config->get_section_keys("params", &keys); - for (String &E : keys) { + for (const String &E : keys) { Variant value = config->get_value("params", E); if (E == "_subresources") { base_subresource_settings = value; @@ -605,7 +605,7 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) { scene_import_settings_data->defaults.clear(); scene_import_settings_data->current.clear(); - for (ResourceImporter::ImportOption &E : options) { + for (const ResourceImporter::ImportOption &E : options) { scene_import_settings_data->defaults[E.option.name] = E.default_value; //needed for visibility toggling (fails if something is missing) if (scene_import_settings_data->settings->has(E.option.name)) { diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp index 5b8f7015fee..0d143472259 100644 --- a/editor/import/scene_importer_mesh.cpp +++ b/editor/import/scene_importer_mesh.cpp @@ -79,7 +79,7 @@ void EditorSceneImporterMesh::add_surface(Mesh::PrimitiveType p_primitive, const List lods; p_lods.get_key_list(&lods); - for (Variant &E : lods) { + for (const Variant &E : lods) { ERR_CONTINUE(!E.is_num()); Surface::LOD lod; lod.distance = E; diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 0b12f868824..7c06ef45160 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -125,7 +125,7 @@ void ImportDefaultsEditor::_update_importer() { d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name()); } - for (ResourceImporter::ImportOption &E : options) { + for (const ResourceImporter::ImportOption &E : options) { settings->properties.push_back(E.option); if (d.has(E.option.name)) { settings->values[E.option.name] = d[E.option.name]; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 3927832eb93..1f8fefbe6e7 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -119,7 +119,7 @@ void ImportDock::set_edit_path(const String &p_path) { import_as->clear(); - for (Pair &E : importer_names) { + for (const Pair &E : importer_names) { import_as->add_item(E.first); import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); if (E.second == importer_name) { @@ -153,7 +153,7 @@ void ImportDock::_update_options(const Ref &p_config) { params->checking = params->paths.size() > 1; params->checked.clear(); - for (ResourceImporter::ImportOption &E : options) { + for (const ResourceImporter::ImportOption &E : options) { params->properties.push_back(E.option); if (p_config.is_valid() && p_config->has_section_key("params", E.option.name)) { params->values[E.option.name] = p_config->get_value("params", E.option.name); @@ -201,7 +201,7 @@ void ImportDock::set_edit_multiple_paths(const Vector &p_paths) { List keys; config->get_section_keys("params", &keys); - for (String &E : keys) { + for (const String &E : keys) { if (!value_frequency.has(E)) { value_frequency[E] = Dictionary(); } @@ -226,7 +226,7 @@ void ImportDock::set_edit_multiple_paths(const Vector &p_paths) { params->checking = true; params->checked.clear(); - for (ResourceImporter::ImportOption &E : options) { + for (const ResourceImporter::ImportOption &E : options) { params->properties.push_back(E.option); if (value_frequency.has(E.option.name)) { @@ -235,7 +235,7 @@ void ImportDock::set_edit_multiple_paths(const Vector &p_paths) { List v; d.get_key_list(&v); Variant value; - for (Variant &F : v) { + for (const Variant &F : v) { int f = d[F]; if (f > freq) { value = F; @@ -262,7 +262,7 @@ void ImportDock::set_edit_multiple_paths(const Vector &p_paths) { import_as->clear(); - for (Pair &E : importer_names) { + for (const Pair &E : importer_names) { import_as->add_item(E.first); import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); if (E.second == params->importer->get_importer_name()) { @@ -363,7 +363,7 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (Variant &E : v) { + for (const Variant &E : v) { params->values[E] = d[E]; if (params->checking) { params->checked.insert(E); @@ -384,7 +384,7 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (ResourceImporter::ImportOption &E : options) { + for (const ResourceImporter::ImportOption &E : options) { params->values[E.option.name] = E.default_value; if (params->checking) { params->checked.insert(E.option.name); @@ -486,7 +486,7 @@ void ImportDock::_reimport() { if (params->checking && config->get_value("remap", "importer") == params->importer->get_importer_name()) { //update only what is edited (checkboxes) if the importer is the same - for (PropertyInfo &E : params->properties) { + for (const PropertyInfo &E : params->properties) { if (params->checked.has(E.name)) { config->set_value("params", E.name, params->values[E.name]); } @@ -498,7 +498,7 @@ void ImportDock::_reimport() { config->erase_section("params"); } - for (PropertyInfo &E : params->properties) { + for (const PropertyInfo &E : params->properties) { config->set_value("params", E.name, params->values[E.name]); } } diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index b1c601a41c6..1973494a2a8 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -87,7 +87,7 @@ void InspectorDock::_menu_option(int p_option) { List props; current->get_property_list(&props); Map duplicates; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index d4b712b6a38..b32ea67d4de 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -43,13 +43,13 @@ void LocalizationEditor::_notification(int p_what) { List tfn; ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); - for (String &E : tfn) { + for (const String &E : tfn) { translation_file_open->add_filter("*." + E); } List rfn; ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); - for (String &E : rfn) { + for (const String &E : rfn) { translation_res_file_open_dialog->add_filter("*." + E); translation_res_option_file_open_dialog->add_filter("*." + E); } @@ -430,7 +430,7 @@ void LocalizationEditor::_update_pot_file_extensions() { pot_file_open_dialog->clear_filters(); List translation_parse_file_extensions; EditorTranslationParser::get_singleton()->get_recognized_extensions(&translation_parse_file_extensions); - for (String &E : translation_parse_file_extensions) { + for (const String &E : translation_parse_file_extensions) { pot_file_open_dialog->add_filter("*." + E); } } @@ -560,7 +560,7 @@ void LocalizationEditor::update_translations() { List rk; remaps.get_key_list(&rk); Vector keys; - for (Variant &E : rk) { + for (const Variant &E : rk) { keys.push_back(E); } keys.sort(); diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 910b242c419..fd4a4334fcc 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -143,7 +143,7 @@ void MultiNodeEdit::_get_property_list(List *p_list) const { List plist; n->get_property_list(&plist, true); - for (PropertyInfo &F : plist) { + for (const PropertyInfo &F : plist) { if (F.name == "script") { continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) } @@ -164,7 +164,7 @@ void MultiNodeEdit::_get_property_list(List *p_list) const { nc++; } - for (PLData *E : data_list) { + for (const PLData *E : data_list) { if (nc == E->uses) { p_list->push_back(E->info); } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index ab11680e2fd..ad2d9866fae 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -72,14 +72,14 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref names; ap->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); animations_to_add.push_back(E); } } } - for (StringName &E : classes) { + for (const StringName &E : classes) { String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; @@ -373,7 +373,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 3fb90eb4ff6..49fcac512b7 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -96,14 +96,14 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref names; ap->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); animations_to_add.push_back(E); } } } - for (StringName &E : classes) { + for (const StringName &E : classes) { String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope @@ -295,7 +295,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 705a1d0fc0f..c94014944cd 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -121,7 +121,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List nodes; blend_tree->get_node_list(&nodes); - for (StringName &E : nodes) { + for (const StringName &E : nodes) { GraphNode *node = memnew(GraphNode); graph->add_child(node); @@ -155,7 +155,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List pinfo; agnode->get_parameter_list(&pinfo); - for (PropertyInfo &F : pinfo) { + for (const PropertyInfo &F : pinfo) { if (!(F.usage & PROPERTY_USAGE_EDITOR)) { continue; } @@ -212,7 +212,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List anims; ap->get_animation_list(&anims); - for (StringName &F : anims) { + for (const StringName &F : anims) { mb->get_popup()->add_item(F); options.push_back(F); } @@ -246,7 +246,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List connections; blend_tree->get_node_connections(&connections); - for (AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; @@ -274,7 +274,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { open_file->clear_filters(); List filters; ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); @@ -394,7 +394,7 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { List conns; blend_tree->get_node_connections(&conns); - for (AnimationNodeBlendTree::NodeConnection &E : conns) { + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { if (E.output_node == p_which || E.input_node == p_which) { undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E.input_node, E.input_index, E.output_node); } @@ -423,7 +423,7 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() { undo_redo->create_action(TTR("Delete Node(s)")); - for (StringName &F : to_erase) { + for (const StringName &F : to_erase) { _delete_request(F); } @@ -517,7 +517,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref &ano List animations; player->get_animation_list(&animations); - for (StringName &E : animations) { + for (const StringName &E : animations) { Ref anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); @@ -718,7 +718,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { List conns; blend_tree->get_node_connections(&conns); - for (AnimationNodeBlendTree::NodeConnection &E : conns) { + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { float activity = 0; StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { @@ -828,7 +828,7 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref connections; blend_tree->get_node_connections(&connections); - for (AnimationNodeBlendTree::NodeConnection &E : connections) { + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { StringName from = E.output_node; StringName to = E.input_node; int to_idx = E.input_index; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 1bdbc2980ce..4ba9147955c 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -350,7 +350,7 @@ void AnimationPlayerEditor::_animation_load() { List extensions; ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions); - for (String &E : extensions) { + for (const String &E : extensions) { file->add_filter("*." + E + " ; " + E.to_upper()); } @@ -584,7 +584,7 @@ void AnimationPlayerEditor::_animation_blend() { blend_editor.next->clear(); blend_editor.next->add_item("", i); - for (StringName &to : anims) { + for (const StringName &to : anims) { TreeItem *blend = blend_editor.tree->create_item(root); blend->set_editable(0, false); blend->set_editable(1, true); @@ -829,7 +829,7 @@ void AnimationPlayerEditor::_update_player() { } int active_idx = -1; - for (StringName &E : animlist) { + for (const StringName &E : animlist) { Ref icon; if (E == player->get_autoplay()) { if (E == "RESET") { @@ -965,7 +965,7 @@ void AnimationPlayerEditor::_animation_duplicate() { Ref new_anim = memnew(Animation); List plist; anim->get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (E.usage & PROPERTY_USAGE_STORAGE) { new_anim->set(E.name, anim->get(E.name)); } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index bee6af3cbbf..a1f96f21bf9 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -93,14 +93,14 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref names; ap->get_animation_list(&names); - for (StringName &E : names) { + for (const StringName &E : names) { animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); animations_to_add.push_back(E); } } } - for (StringName &E : classes) { + for (const StringName &E : classes) { String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope @@ -318,7 +318,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Refclear_filters(); List filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (String &E : filters) { + for (const String &E : filters) { open_file->add_filter("*." + E); } open_file->popup_file_dialog(); @@ -606,7 +606,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } //pre pass nodes so we know the rectangles - for (StringName &E : nodes) { + for (const StringName &E : nodes) { Ref anode = state_machine->get_node(E); String name = E; bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr()); diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 67d5600a3ca..cd84be0c25c 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -215,7 +215,7 @@ Vector AnimationTreeEditor::get_animation_list() { List anims; ap->get_animation_list(&anims); Vector ret; - for (StringName &E : anims) { + for (const StringName &E : anims) { ret.push_back(E); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8b9e76b4026..869a582d96e 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -399,7 +399,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig if ((is_snap_active && snap_other_nodes && (p_modes & SNAP_OTHER_NODES)) || (p_forced_modes & SNAP_OTHER_NODES)) { Transform2D to_snap_transform = Transform2D(); List exceptions = List(); - for (CanvasItem *E : p_other_nodes_exceptions) { + for (const CanvasItem *E : p_other_nodes_exceptions) { exceptions.push_back(E); } if (p_self_canvas_item) { @@ -842,7 +842,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List p_canvas_ite undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); if (commit_bones) { - for (Dictionary &F : se->pre_drag_bones_undo_state) { + for (const Dictionary &F : se->pre_drag_bones_undo_state) { canvas_item = Object::cast_to(canvas_item->get_parent()); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); @@ -3555,7 +3555,7 @@ void CanvasItemEditor::_draw_hover() { Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4); // Rectify the position to avoid overlapping items - for (Rect2 &E : previous_rects) { + for (const Rect2 &E : previous_rects) { if (E.intersects(Rect2(pos, item_size))) { pos.y = E.get_position().y - item_size.y; } @@ -4699,7 +4699,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } undo_redo->create_action(TTR("Paste Pose")); - for (PoseClipboard &E : pose_clipboard) { + for (const PoseClipboard &E : pose_clipboard) { Node2D *n2d = Object::cast_to(ObjectDB::get_instance(E.id)); if (!n2d) { continue; diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 7e0eb89359d..6f246c1661e 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -253,7 +253,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List ext; ImageLoader::get_recognized_extensions(&ext); - for (String &E : ext) { + for (const String &E : ext) { file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 19204e3bf88..81c340e9a40 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -490,7 +490,7 @@ Ref EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Set control_flow_keywords; Set keywords; - for (String &E : kwors) { + for (const String &E : kwors) { if (scr->get_language()->is_control_flow_keyword(E)) { control_flow_keywords.insert(E); } else { diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 4412d51077b..5184e837ce5 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -361,7 +361,7 @@ GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List ext; ImageLoader::get_recognized_extensions(&ext); - for (String &E : ext) { + for (const String &E : ext) { file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 32d5865d0b8..94966d4fe61 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -265,7 +265,7 @@ Ref StandardMaterial3DConversionPlugin::convert(const Ref &p List params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself Ref texture = mat->get_texture_by_name(E.name); @@ -309,7 +309,7 @@ Ref ParticlesMaterialConversionPlugin::convert(const Ref &p_ List params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -346,7 +346,7 @@ Ref CanvasItemMaterialConversionPlugin::convert(const Ref &p List params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -383,7 +383,7 @@ Ref ProceduralSkyMaterialConversionPlugin::convert(const Ref List params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -420,7 +420,7 @@ Ref PanoramaSkyMaterialConversionPlugin::convert(const Ref & List params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } @@ -457,7 +457,7 @@ Ref PhysicalSkyMaterialConversionPlugin::convert(const Ref & List params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); smat->set_shader_param(E.name, value); } diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 393aaff2076..2138f943da2 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -4746,7 +4746,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (Face3 &f : faces) { + for (const Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 0cb5a2e1e4d..cbea2405b85 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -181,13 +181,13 @@ void ResourcePreloaderEditor::_update_library() { preloader->get_resource_list(&rnames); List names; - for (StringName &E : rnames) { + for (const StringName &E : rnames) { names.push_back(E); } names.sort(); - for (String &E : names) { + for (const String &E : names) { TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING); ti->set_editable(0, true); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 95e23d0c57f..ed91f174d12 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -70,7 +70,7 @@ void EditorPropertyRootMotion::_node_assign() { List animations; player->get_animation_list(&animations); - for (StringName &E : animations) { + for (const StringName &E : animations) { Ref anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { paths.insert(anim->track_get_path(i)); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index ab783c87e9e..668a15da372 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -103,7 +103,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List types; ClassDB::get_class_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); @@ -115,7 +115,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List global_classes; ScriptServer::get_global_class_list(&global_classes); - for (StringName &E : global_classes) { + for (const StringName &E : global_classes) { highlighter->add_keyword_color(E, usertype_color); } @@ -134,7 +134,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List core_types; script->get_language()->get_core_type_words(&core_types); - for (String &E : core_types) { + for (const String &E : core_types) { highlighter->add_keyword_color(E, basetype_color); } @@ -143,7 +143,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List keywords; script->get_language()->get_reserved_words(&keywords); - for (String &E : keywords) { + for (const String &E : keywords) { if (script->get_language()->is_control_flow_keyword(E)) { highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -157,7 +157,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List plist; ClassDB::get_property_list(instance_base, &plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { String name = E.name; if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; @@ -170,7 +170,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { List clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (String &E : clist) { + for (const String &E : clist) { highlighter->add_member_keyword_color(E, member_variable_color); } } @@ -179,7 +179,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List comments; script->get_language()->get_comment_delimiters(&comments); - for (String &comment : comments) { + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, comment_color, end == ""); @@ -189,7 +189,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List strings; script->get_language()->get_string_delimiters(&strings); - for (String &string : strings) { + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, string_color, end == ""); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index f9a0f307c39..65459d159d8 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -50,7 +50,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector p_n List all_connections; p_nodes[i]->get_signals_connected_to_this(&all_connections); - for (Connection &connection : all_connections) { + for (const Connection &connection : all_connections) { if (connection.callable.get_method() != p_method) { continue; } @@ -114,7 +114,7 @@ Vector ScriptTextEditor::get_functions() { if (script->get_language()->validate(text, script->get_path(), &fnc)) { //if valid rewrite functions to latest functions.clear(); - for (String &E : fnc) { + for (const String &E : fnc) { functions.push_back(E); } } @@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { List strings; script->get_language()->get_string_delimiters(&strings); text_edit->clear_string_delimiters(); - for (String &string : strings) { + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); text_edit->add_string_delimiter(beg, end, end == ""); @@ -210,7 +210,7 @@ void ScriptTextEditor::_set_theme_for_script() { List comments; script->get_language()->get_comment_delimiters(&comments); text_edit->clear_comment_delimiters(); - for (String &comment : comments) { + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); text_edit->add_comment_delimiter(beg, end, end == ""); @@ -413,7 +413,7 @@ void ScriptTextEditor::_validate_script() { } functions.clear(); - for (String &E : fnc) { + for (const String &E : fnc) { functions.push_back(E); } script_is_valid = true; @@ -428,7 +428,7 @@ void ScriptTextEditor::_validate_script() { Node *base = get_tree()->get_edited_scene_root(); if (base && missing_connections.size() > 0) { warnings_panel->push_table(1); - for (Connection &connection : missing_connections) { + for (const Connection &connection : missing_connections) { String base_path = base->get_name(); String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to(connection.signal.get_object())); String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to(connection.callable.get_object())); @@ -450,7 +450,7 @@ void ScriptTextEditor::_validate_script() { // Add script warnings. warnings_panel->push_table(3); - for (ScriptLanguage::Warning &w : warnings) { + for (const ScriptLanguage::Warning &w : warnings) { Dictionary ignore_meta; ignore_meta["line"] = w.start_line; ignore_meta["code"] = w.string_code.to_lower(); @@ -480,7 +480,7 @@ void ScriptTextEditor::_validate_script() { errors_panel->clear(); errors_panel->push_table(2); - for (ScriptLanguage::ScriptError &err : errors) { + for (const ScriptLanguage::ScriptError &err : errors) { errors_panel->push_cell(); errors_panel->push_meta(err.line - 1); errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); @@ -501,7 +501,7 @@ void ScriptTextEditor::_validate_script() { if (errors.is_empty()) { te->set_line_background_color(i, Color(0, 0, 0, 0)); } else { - for (ScriptLanguage::ScriptError &E : errors) { + for (const ScriptLanguage::ScriptError &E : errors) { bool error_line = i == E.line - 1; te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0)); if (error_line) { @@ -900,7 +900,7 @@ void ScriptTextEditor::_update_connected_methods() { List connections; nodes[i]->get_signals_connected_to_this(&connections); - for (Connection &connection : connections) { + for (const Connection &connection : connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } @@ -1275,7 +1275,7 @@ void ScriptTextEditor::_edit_option_toggle_inline_comment() { List comment_delimiters; script->get_language()->get_comment_delimiters(&comment_delimiters); - for (String &script_delimiter : comment_delimiters) { + for (const String &script_delimiter : comment_delimiters) { if (script_delimiter.find(" ") == -1) { delimiter = script_delimiter; break; diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 6c589ee07c0..95870a0f3cb 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -118,7 +118,7 @@ void ShaderTextEditor::_load_theme_settings() { const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); - for (String &E : keywords) { + for (const String &E : keywords) { if (ShaderLanguage::is_control_flow_keyword(E)) { syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -144,7 +144,7 @@ void ShaderTextEditor::_load_theme_settings() { const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); - for (String &E : built_ins) { + for (const String &E : built_ins) { syntax_highlighter->add_keyword_color(E, member_variable_color); } diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 486a40a4fdd..a5d0ebbc128 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -788,7 +788,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { anim_names.sort_custom(); - for (StringName &E : anim_names) { + for (const StringName &E : anim_names) { String name = E; TreeItem *it = animations->create_item(anim_root); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 34227ee8940..b277f2ab42e 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -144,7 +144,7 @@ void TextureRegionEditor::_region_draw() { } } } else if (snap_mode == SNAP_AUTOSLICE) { - for (Rect2 &r : autoslice_cache) { + for (const Rect2 &r : autoslice_cache) { Vector2 endpoints[4] = { mtx.basis_xform(r.position), mtx.basis_xform(r.position + Vector2(r.size.x, 0)), @@ -327,7 +327,7 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { } if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) { Vector2 point = mtx.affine_inverse().xform(Vector2(mb->get_position().x, mb->get_position().y)); - for (Rect2 &E : autoslice_cache) { + for (const Rect2 &E : autoslice_cache) { if (E.has_point(point)) { rect = E; if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 991c298caa2..df6e9e66149 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -65,7 +65,7 @@ void ThemeItemImportTree::_update_items_tree() { tree_icon_items.clear(); tree_stylebox_items.clear(); - for (StringName &E : types) { + for (const StringName &E : types) { String type_name = (String)E; TreeItem *type_node = import_items_tree->create_item(root); @@ -93,7 +93,7 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_has_filtered_items = false; - for (StringName &F : names) { + for (const StringName &F : names) { String item_name = (String)F; bool is_item_matching_filter = (item_name.findn(filter_text) > -1); if (!filter_text.is_empty() && !is_matching_filter && !is_item_matching_filter) { @@ -182,7 +182,7 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_any_checked_with_data = false; filtered_names.sort_custom(); - for (StringName &F : filtered_names) { + for (const StringName &F : filtered_names) { TreeItem *item_node = import_items_tree->create_item(data_type_node); item_node->set_meta("_can_be_imported", true); item_node->set_text(0, F); @@ -1236,7 +1236,7 @@ void ThemeItemEditorDialog::_update_edit_types() { bool item_reselected = false; edit_type_list->clear(); int e_idx = 0; - for (StringName &E : theme_types) { + for (const StringName &E : theme_types) { Ref item_icon; if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); @@ -1318,7 +1318,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { color_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(color_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1339,7 +1339,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { constant_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(constant_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1360,7 +1360,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { font_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1381,7 +1381,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { font_size_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_size_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1402,7 +1402,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { icon_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(icon_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1423,7 +1423,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { stylebox_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(stylebox_root); item->set_text(0, E); item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); @@ -1507,7 +1507,7 @@ void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, edited_theme->_freeze_change_propagation(); edited_theme->get_theme_item_list(p_data_type, p_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { edited_theme->clear_theme_item(p_data_type, E, p_item_type); } @@ -1526,7 +1526,7 @@ void ThemeItemEditorDialog::_remove_class_items() { names.clear(); Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (edited_theme->has_theme_item_nocheck(data_type, E, edited_item_type)) { edited_theme->clear_theme_item(data_type, E, edited_item_type); } @@ -1550,7 +1550,7 @@ void ThemeItemEditorDialog::_remove_custom_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!Theme::get_default()->has_theme_item_nocheck(data_type, E, edited_item_type)) { edited_theme->clear_theme_item(data_type, E, edited_item_type); } @@ -1574,7 +1574,7 @@ void ThemeItemEditorDialog::_remove_all_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { edited_theme->clear_theme_item(data_type, E, edited_item_type); } } @@ -1927,7 +1927,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { import_another_theme_dialog->set_title(TTR("Select Another Theme Resource:")); List ext; ResourceLoader::get_recognized_extensions_for_type("Theme", &ext); - for (String &E : ext) { + for (const String &E : ext) { import_another_theme_dialog->add_filter("*." + E + "; Theme Resource"); } import_another_file_hb->add_child(import_another_theme_dialog); @@ -1969,7 +1969,7 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { names.sort_custom(); Vector unique_names; - for (StringName &E : names) { + for (const StringName &E : names) { // Filter out undesired values. if (!p_filter.is_subsequence_ofi(String(E))) { continue; @@ -2132,7 +2132,7 @@ void ThemeTypeEditor::_update_type_list() { bool item_reselected = false; int e_idx = 0; - for (StringName &E : theme_types) { + for (const StringName &E : theme_types) { Ref item_icon; if (E == "") { item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); @@ -2182,7 +2182,7 @@ OrderedHashMap ThemeTypeEditor::_get_type_items(String p_type_ (Theme::get_default().operator->()->*get_list_func)(default_type, &names); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { items[E] = false; } } @@ -2191,7 +2191,7 @@ OrderedHashMap ThemeTypeEditor::_get_type_items(String p_type_ names.clear(); (edited_theme.operator->()->*get_list_func)(p_type_name, &names); names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { items[E] = true; } } @@ -2203,7 +2203,7 @@ OrderedHashMap ThemeTypeEditor::_get_type_items(String p_type_ keys.sort_custom(); OrderedHashMap ordered_items; - for (StringName &E : keys) { + for (const StringName &E : keys) { ordered_items[E] = items[E]; } @@ -2580,7 +2580,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_icon_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_icon(E, edited_type)) { edited_theme->set_icon(E, edited_type, Ref()); } @@ -2589,7 +2589,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_stylebox_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_stylebox(E, edited_type)) { edited_theme->set_stylebox(E, edited_type, Ref()); } @@ -2598,7 +2598,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_font_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_font(E, edited_type)) { edited_theme->set_font(E, edited_type, Ref()); } @@ -2607,7 +2607,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_font_size_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_font_size(E, edited_type)) { edited_theme->set_font_size(E, edited_type, Theme::get_default()->get_font_size(E, default_type)); } @@ -2616,7 +2616,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_color_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_color(E, edited_type)) { edited_theme->set_color(E, edited_type, Theme::get_default()->get_color(E, default_type)); } @@ -2625,7 +2625,7 @@ void ThemeTypeEditor::_add_default_type_items() { { names.clear(); Theme::get_default()->get_constant_list(default_type, &names); - for (StringName &E : names) { + for (const StringName &E : names) { if (!edited_theme->has_constant(E, edited_type)) { edited_theme->set_constant(E, edited_type, Theme::get_default()->get_constant(E, default_type)); } @@ -2882,7 +2882,7 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List names; edited_theme->get_stylebox_list(edited_type, &names); List> styleboxes; - for (StringName &E : names) { + for (const StringName &E : names) { if (E == leading_stylebox.item_name) { continue; } @@ -2895,7 +2895,7 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List props; leading_stylebox.stylebox->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -3301,7 +3301,7 @@ ThemeEditor::ThemeEditor() { preview_scene_dialog->set_title(TTR("Select UI Scene:")); List ext; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &ext); - for (String &E : ext) { + for (const String &E : ext) { preview_scene_dialog->add_filter("*." + E + "; Scene"); } main_hs->add_child(preview_scene_dialog); @@ -3343,11 +3343,11 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List names; edited_theme->get_font_type_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { names.clear(); edited_theme->get_font_list(E, &names); - for (StringName &F : names) { + for (const StringName &F : names) { if (font_item == edited_theme->get_font(F, E)) { belongs_to_theme = true; break; @@ -3360,11 +3360,11 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List names; edited_theme->get_stylebox_type_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { names.clear(); edited_theme->get_stylebox_list(E, &names); - for (StringName &F : names) { + for (const StringName &F : names) { if (stylebox_item == edited_theme->get_stylebox(F, E)) { belongs_to_theme = true; break; @@ -3377,11 +3377,11 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List names; edited_theme->get_icon_type_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { names.clear(); edited_theme->get_icon_list(E, &names); - for (StringName &F : names) { + for (const StringName &F : names) { if (icon_item == edited_theme->get_icon(F, E)) { belongs_to_theme = true; break; diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index ab26e1c380f..432f48fa854 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -303,7 +303,7 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(Listuses == tiles.size()) { p_list->push_back(E->property_info); } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 7e3244dddfe..46818afe45e 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -666,7 +666,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_left) { name_left = vsnode->get_input_port_name(i); port_left = vsnode->get_input_port_type(i); - for (VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : connections) { if (E.to_node == p_id && E.to_port == j) { port_left_used = true; } @@ -899,7 +899,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->set_syntax_highlighter(expression_syntax_highlighter); expression_box->add_theme_color_override("background_color", background_color); - for (String &E : VisualShaderEditor::get_singleton()->keyword_list) { + for (const String &E : VisualShaderEditor::get_singleton()->keyword_list) { if (ShaderLanguage::is_control_flow_keyword(E)) { expression_syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -1470,7 +1470,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (VisualShader::Connection &E : connections) { + for (const VisualShader::Connection &E : connections) { int from = E.from_node; int from_idx = E.from_port; int to = E.to_node; @@ -1634,7 +1634,7 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { int from_node = E.from_node; int from_port = E.from_port; int to_node = E.to_node; @@ -1708,7 +1708,7 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { int from_node = E.from_node; int from_port = E.from_port; int to_node = E.to_node; @@ -1757,7 +1757,7 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { int from_node = E.from_node; int from_port = E.from_port; int to_node = E.to_node; @@ -2518,7 +2518,7 @@ void VisualShaderEditor::_nodes_dragged() { undo_redo->create_action(TTR("Node(s) Moved")); - for (DragOp &E : drag_buffer) { + for (const DragOp &E : drag_buffer) { undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.to); undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.from); undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.to); @@ -2544,7 +2544,7 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.to_node == to && E.to_port == p_to_index) { undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -2598,7 +2598,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List &p_nodes) { visual_shader->get_node_connections(type, &conns); for (const int &F : p_nodes) { - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == F || E.to_node == F) { undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } @@ -2639,7 +2639,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List &p_nodes) { List used_conns; for (const int &F : p_nodes) { - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == F || E.to_node == F) { bool cancel = false; for (List::Element *R = used_conns.front(); R; R = R->next()) { @@ -3094,7 +3094,7 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); - for (String &E : keyword_list) { + for (const String &E : keyword_list) { if (ShaderLanguage::is_control_flow_keyword(E)) { syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { @@ -3249,7 +3249,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List conns; visual_shader->get_node_connections(pasted_type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (unsupported_set.has(E.from_node) || unsupported_set.has(E.to_node)) { continue; } @@ -3399,7 +3399,7 @@ void VisualShaderEditor::_input_select_item(Ref p_input, if (type_changed) { List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == id) { if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -3445,7 +3445,7 @@ void VisualShaderEditor::_uniform_select_item(Ref p_ if (type_changed) { List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.from_node == id) { if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; @@ -4825,7 +4825,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref &p_par Vector pinfo; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { for (int i = 0; i < properties.size(); i++) { if (E.name == String(properties[i])) { pinfo.push_back(E); @@ -4894,7 +4894,7 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { VisualShader::Type type = VisualShader::Type(i); List conns; visual_shader->get_node_connections(type, &conns); - for (VisualShader::Connection &E : conns) { + for (const VisualShader::Connection &E : conns) { if (E.to_node == VisualShader::NODE_ID_OUTPUT) { undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } @@ -4918,7 +4918,7 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { List props; visual_shader->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (E.name.begins_with("flags/") || E.name.begins_with("modes/")) { undo_redo->add_undo_property(visual_shader.ptr(), E.name, visual_shader->get(E.name)); } @@ -5024,7 +5024,7 @@ void VisualShaderNodePortPreview::_shader_changed() { if (src_mat && src_mat->get_shader().is_valid()) { List params; src_mat->get_shader()->get_param_list(¶ms); - for (PropertyInfo &E : params) { + for (const PropertyInfo &E : params) { material->set(E.name, src_mat->get(E.name)); } } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 3f320ef12a6..fcb714bdf71 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -340,7 +340,7 @@ void ProjectExportDialog::_update_feature_list() { } } - for (String &E : features) { + for (const String &E : features) { fset.insert(E); } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 4f9d849bc02..fd4f22425f4 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1238,14 +1238,14 @@ void ProjectList::load_projects() { Set favorites; // Find favourites... - for (PropertyInfo &E : properties) { + for (const PropertyInfo &E : properties) { String property_key = E.name; if (property_key.begins_with("favorite_projects/")) { favorites.insert(property_key); } } - for (PropertyInfo &E : properties) { + for (const PropertyInfo &E : properties) { // This is actually something like "projects/C:::Documents::Godot::Projects::MyGame" String property_key = E.name; if (!property_key.begins_with("projects/")) { @@ -1582,7 +1582,7 @@ int ProjectList::refresh_project(const String &dir_path) { String favorite_property_key = "favorite_projects/" + project_key; bool found = false; - for (PropertyInfo &E : properties) { + for (const PropertyInfo &E : properties) { String prop = E.name; if (!found && prop == property_key) { found = true; @@ -2188,7 +2188,7 @@ void ProjectManager::_scan_begin(const String &p_base) { _scan_dir(p_base, &projects); print_line("Found " + itos(projects.size()) + " projects."); - for (String &E : projects) { + for (const String &E : projects) { String proj = get_project_key_from_path(E); EditorSettings::get_singleton()->set("projects/" + proj, E); } @@ -2625,7 +2625,7 @@ ProjectManager::ProjectManager() { Vector editor_languages; List editor_settings_properties; EditorSettings::get_singleton()->get_property_list(&editor_settings_properties); - for (PropertyInfo &pi : editor_settings_properties) { + for (const PropertyInfo &pi : editor_settings_properties) { if (pi.name == "interface/editor/editor_language") { editor_languages = pi.hint_string.split(","); break; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index bc44fccfa09..b8ccab78ddb 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -229,7 +229,7 @@ void ProjectSettingsEditor::_add_feature_overrides() { for (int i = 0; i < ee->get_export_platform_count(); i++) { List p; ee->get_export_platform(i)->get_platform_features(&p); - for (String &E : p) { + for (const String &E : p) { presets.insert(E); } } @@ -237,7 +237,7 @@ void ProjectSettingsEditor::_add_feature_overrides() { for (int i = 0; i < ee->get_export_preset_count(); i++) { List p; ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p); - for (String &E : p) { + for (const String &E : p) { presets.insert(E); } @@ -391,7 +391,7 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const undo_redo->create_action(TTR("Update Input Action Order")); - for (PropertyInfo &prop : props) { + for (const PropertyInfo &prop : props) { // Skip builtins and non-inputs if (ProjectSettings::get_singleton()->is_builtin_setting(prop.name) || !prop.name.begins_with("input/")) { continue; @@ -444,7 +444,7 @@ void ProjectSettingsEditor::_update_action_map_editor() { ProjectSettings::get_singleton()->get_property_list(&props); const Ref builtin_icon = get_theme_icon(SNAME("PinPressed"), SNAME("EditorIcons")); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { const String property_name = E.name; if (!property_name.begins_with("input/")) { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 6fc77500c3e..7338588d56c 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -143,7 +143,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { } Set valid_extensions; - for (String &E : extensions) { + for (const String &E : extensions) { valid_extensions.insert(E); } @@ -179,7 +179,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { res_orig->get_property_list(&property_list); List> propvalues; - for (PropertyInfo &pi : property_list) { + for (const PropertyInfo &pi : property_list) { Pair p; if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; @@ -197,7 +197,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); - for (Pair &p : propvalues) { + for (const Pair &p : propvalues) { res->set(p.first, p.second); } @@ -1291,7 +1291,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type, &extensions); file->clear_filters(); - for (String &E : extensions) { + for (const String &E : extensions) { file->add_filter("*." + E + " ; " + E.to_upper()); } @@ -1319,7 +1319,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { res_orig->get_property_list(&property_list); List> propvalues; - for (PropertyInfo &pi : property_list) { + for (const PropertyInfo &pi : property_list) { Pair p; if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; @@ -1333,7 +1333,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_FAIL_COND(res.is_null()); - for (Pair &p : propvalues) { + for (const Pair &p : propvalues) { res->set(p.first, p.second); } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 471fec76f27..a1deae92a41 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -156,7 +156,7 @@ void PropertySelector::_update_search() { search_options->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (E.usage == PROPERTY_USAGE_CATEGORY) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 2586a369661..c4d47c7594f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1531,7 +1531,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map *p_ List properties; p_base->get_property_list(&properties); - for (PropertyInfo &E : properties) { + for (const PropertyInfo &E : properties) { if (!(E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { continue; } @@ -1557,7 +1557,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map *p_ Map::Element *found_root_path = p_renames->find(root); NodePath new_root_path = found_root_path ? found_root_path->get() : root->get_path(); if (!new_root_path.is_empty()) { // No renaming if root node is deleted. - for (StringName &E : anims) { + for (const StringName &E : anims) { Ref anim = ap->get_animation(E); if (!r_rem_anims->has(anim)) { r_rem_anims->insert(anim, Set()); @@ -2271,7 +2271,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List pinfo; n->get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -2308,12 +2308,11 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List sl; n->get_signal_list(&sl); - for (MethodInfo &E : sl) { + for (const MethodInfo &E : sl) { List cl; n->get_signal_connection_list(E.name, &cl); - for (Object::Connection &F : cl) { - Object::Connection &c = F; + for (const Object::Connection &c : cl) { if (!(c.flags & Object::CONNECT_PERSIST)) { continue; } @@ -2519,13 +2518,13 @@ void SceneTreeDock::_files_dropped(Vector p_files, NodePath p_to, int p_ List pinfo; node->get_property_list(&pinfo); - for (PropertyInfo &p : pinfo) { + for (const PropertyInfo &p : pinfo) { if (!(p.usage & PROPERTY_USAGE_EDITOR) || !(p.usage & PROPERTY_USAGE_STORAGE) || p.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } Vector valid_types = p.hint_string.split(","); - for (String &prop_type : valid_types) { + for (const String &prop_type : valid_types) { if (res_type == prop_type || ClassDB::is_parent_class(res_type, prop_type) || EditorNode::get_editor_data().script_class_is_parent(res_type, prop_type)) { valid_properties.push_back(p.name); break; @@ -2539,7 +2538,7 @@ void SceneTreeDock::_files_dropped(Vector p_files, NodePath p_to, int p_ bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties")); menu_properties->clear(); - for (String &p : valid_properties) { + for (const String &p : valid_properties) { menu_properties->add_item(capitalize ? p.capitalize() : p); menu_properties->set_item_metadata(menu_properties->get_item_count() - 1, p); } @@ -2597,7 +2596,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { List pinfo; p_obj->get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } @@ -3052,7 +3051,7 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map &r_remap) p_node->get_property_list(&props); bool is_instantiated = EditorPropertyRevert::may_node_be_in_instance(p_node); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -3088,7 +3087,7 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map &r_ List props; p_resource->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 90481b21070..9a4b38db742 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -205,7 +205,7 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must bool found = false; bool match = false; int index = 0; - for (String &E : extensions) { + for (const String &E : extensions) { if (E.nocasecmp_to(extension) == 0) { //FIXME (?) - changing language this way doesn't update controls, needs rework //language_menu->select(index); // change Language option by extension @@ -373,7 +373,7 @@ void ScriptCreateDialog::_lang_changed(int l) { ScriptServer::get_language(m)->get_recognized_extensions(&extensions); } - for (String &E : extensions) { + for (const String &E : extensions) { if (E.nocasecmp_to(extension) == 0) { path = path.get_basename() + selected_ext; _path_changed(path); @@ -534,7 +534,7 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { int lang = language_menu->get_selected(); ScriptServer::get_language(lang)->get_recognized_extensions(&extensions); - for (String &E : extensions) { + for (const String &E : extensions) { file_browse->add_filter("*." + E); } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 89e102ee227..aefa8e434e8 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -324,7 +324,7 @@ void EditorSettingsDialog::_update_shortcuts() { List slist; EditorSettings::get_singleton()->get_shortcut_list(&slist); - for (String &E : slist) { + for (const String &E : slist) { Ref sc = EditorSettings::get_singleton()->get_shortcut(E); if (!sc->has_meta("original")) { continue; diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index b585ad15bf3..9445fac1c62 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -129,7 +129,7 @@ void GDNativeLibrary::_get_property_list(List *p_list) const { config_file->get_section_keys("entry", &entry_key_list); } - for (String &key : entry_key_list) { + for (const String &key : entry_key_list) { PropertyInfo prop; prop.type = Variant::STRING; @@ -145,7 +145,7 @@ void GDNativeLibrary::_get_property_list(List *p_list) const { config_file->get_section_keys("dependencies", &dependency_key_list); } - for (String &key : dependency_key_list) { + for (const String &key : dependency_key_list) { PropertyInfo prop; prop.type = Variant::STRING; @@ -171,7 +171,7 @@ void GDNativeLibrary::set_config_file(Ref p_config_file) { p_config_file->get_section_keys("entry", &entry_keys); } - for (String &key : entry_keys) { + for (const String &key : entry_keys) { Vector tags = key.split("."); bool skip = false; @@ -201,7 +201,7 @@ void GDNativeLibrary::set_config_file(Ref p_config_file) { p_config_file->get_section_keys("dependencies", &dependency_keys); } - for (String &key : dependency_keys) { + for (const String &key : dependency_keys) { Vector tags = key.split("."); bool skip = false; diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 0a3225fcc5f..df0f29277ee 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -425,7 +425,7 @@ List generate_c_api_classes() { List enums; List enum_names; ClassDB::get_enum_list(class_name, &enum_names, true); - for (StringName &E : enum_names) { + for (const StringName &E : enum_names) { List value_names; EnumAPI enum_api; enum_api.name = E; diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index dba348c20de..f3a0e9603fa 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -98,7 +98,7 @@ void NativeScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) List info; get_script_property_list(&info); Map values; - for (PropertyInfo &E : info) { + for (const PropertyInfo &E : info) { Variant value; get_property_default_value(E.name, value); values[E.name] = value; diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index c3a6a3267fc..a41c4f7b19b 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -79,7 +79,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List entry_keys; config->get_section_keys("entry", &entry_keys); - for (String &key : entry_keys) { + for (const String &key : entry_keys) { Vector tags = key.split("."); bool skip = false; @@ -110,7 +110,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List dependency_keys; config->get_section_keys("dependencies", &dependency_keys); - for (String &key : dependency_keys) { + for (const String &key : dependency_keys) { Vector tags = key.split("."); bool skip = false; @@ -145,7 +145,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty List entry_keys; config->get_section_keys("entry", &entry_keys); - for (String &key : entry_keys) { + for (const String &key : entry_keys) { Vector tags = key.split("."); bool skip = false; diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index b19a57d56a7..ed8b0a46907 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -458,7 +458,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color types_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List types; ClassDB::get_class_list(&types); - for (StringName &E : types) { + for (const StringName &E : types) { String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); @@ -470,7 +470,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List global_classes; ScriptServer::get_global_class_list(&global_classes); - for (StringName &E : global_classes) { + for (const StringName &E : global_classes) { keywords[String(E)] = usertype_color; } @@ -489,7 +489,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List core_types; gdscript->get_core_type_words(&core_types); - for (String &E : core_types) { + for (const String &E : core_types) { keywords[E] = basetype_color; } @@ -498,7 +498,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List keyword_list; gdscript->get_reserved_words(&keyword_list); - for (String &E : keyword_list) { + for (const String &E : keyword_list) { if (gdscript->is_control_flow_keyword(E)) { keywords[E] = control_flow_keyword_color; } else { @@ -510,7 +510,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List comments; gdscript->get_comment_delimiters(&comments); - for (String &comment : comments) { + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); add_color_region(beg, end, comment_color, end == ""); @@ -520,7 +520,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List strings; gdscript->get_string_delimiters(&strings); - for (String &string : strings) { + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); add_color_region(beg, end, string_color, end == ""); @@ -534,7 +534,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List plist; ClassDB::get_property_list(instance_base, &plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { String name = E.name; if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; @@ -547,7 +547,7 @@ void GDScriptSyntaxHighlighter::_update_cache() { List clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (String &E : clist) { + for (const String &E : clist) { member_keywords[E] = member_variable_color; } } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 79cc90b92f5..b3975fa95cd 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -291,7 +291,7 @@ void GDScript::_get_script_property_list(List *r_list, bool p_incl sptr = sptr->_base; } - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { r_list->push_back(E); } } @@ -401,7 +401,7 @@ void GDScript::_update_exports_values(Map &values, Listkey()] = E->get(); } - for (PropertyInfo &E : members_cache) { + for (const PropertyInfo &E : members_cache) { propnames.push_back(E); } } @@ -861,8 +861,7 @@ Error GDScript::reload(bool p_keep_state) { } } #ifdef DEBUG_ENABLED - for (const GDScriptWarning &E : parser.get_warnings()) { - const GDScriptWarning &warning = E; + for (const GDScriptWarning &warning : parser.get_warnings()) { if (EngineDebugger::is_active()) { Vector si; EngineDebugger::get_script_debugger()->send_error("", get_path(), warning.start_line, warning.get_name(), warning.get_message(), ERR_HANDLER_WARNING, si); @@ -1445,7 +1444,7 @@ void GDScriptInstance::get_property_list(List *p_properties) const sptr = sptr->_base; } - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { p_properties->push_back(E); } } @@ -1661,7 +1660,7 @@ void GDScriptLanguage::init() { List singletons; Engine::get_singleton()->get_singletons(&singletons); - for (Engine::Singleton &E : singletons) { + for (const Engine::Singleton &E : singletons) { _add_global(E.name, E.ptr); } diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 3289f8978b8..7c9d08b7822 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -981,7 +981,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code assigned = prev_base; // Set back the values into their bases. - for (ChainInfo &info : set_chain) { + for (const ChainInfo &info : set_chain) { if (!info.is_named) { gen->write_set(info.base, info.key, assigned); if (info.key.mode == GDScriptCodeGenerator::Address::TEMPORARY) { diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 3ac9db3645f..2a93bb620b9 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -319,7 +319,7 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List *p List> locals; f->debug_get_stack_member_state(*_call_stack[l].line, &locals); - for (Pair &E : locals) { + for (const Pair &E : locals) { p_locals->push_back(E.first); p_values->push_back(_call_stack[l].stack[E.second]); } @@ -865,7 +865,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!_static) { List members; scr->get_script_property_list(&members); - for (PropertyInfo &E : members) { + for (const PropertyInfo &E : members) { ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); } @@ -879,7 +879,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List signals; scr->get_script_signal_list(&signals); - for (MethodInfo &E : signals) { + for (const MethodInfo &E : signals) { ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_SIGNAL); r_result.insert(option.display, option); } @@ -887,7 +887,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List methods; scr->get_script_method_list(&methods); - for (MethodInfo &E : methods) { + for (const MethodInfo &E : methods) { if (E.name.begins_with("@")) { continue; } @@ -920,7 +920,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!p_only_functions) { List constants; ClassDB::get_integer_constant_list(type, &constants); - for (String &E : constants) { + for (const String &E : constants) { ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT); r_result.insert(option.display, option); } @@ -928,7 +928,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base if (!_static || Engine::get_singleton()->has_singleton(type)) { List pinfo; ClassDB::get_property_list(type, &pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY)) { continue; } @@ -945,7 +945,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base List methods; bool is_autocompleting_getters = GLOBAL_GET("debug/gdscript/completion/autocomplete_setters_and_getters").booleanize(); ClassDB::get_method_list(type, &methods, false, !is_autocompleting_getters); - for (MethodInfo &E : methods) { + for (const MethodInfo &E : methods) { if (E.name.begins_with("_")) { continue; } @@ -977,7 +977,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base tmp.get_property_list(&members); } - for (PropertyInfo &E : members) { + for (const PropertyInfo &E : members) { if (String(E.name).find("/") == -1) { ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER); r_result.insert(option.display, option); @@ -2095,7 +2095,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex if (scr.is_valid()) { List methods; scr->get_script_method_list(&methods); - for (MethodInfo &mi : methods) { + for (const MethodInfo &mi : methods) { if (mi.name == p_method) { r_type = _type_from_property(mi.return_val); return true; @@ -2135,7 +2135,7 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex List methods; tmp.get_method_list(&methods); - for (MethodInfo &mi : methods) { + for (const MethodInfo &mi : methods) { if (mi.name == p_method) { r_type = _type_from_property(mi.return_val); return true; @@ -2180,7 +2180,7 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co List enum_constants; ClassDB::get_enum_constants(class_name, enum_name, &enum_constants); - for (StringName &E : enum_constants) { + for (const StringName &E : enum_constants) { String candidate = class_name + "." + E; ScriptCodeCompletionOption option(candidate, ScriptCodeCompletionOption::KIND_ENUM); r_result.insert(option.display, option); @@ -2225,7 +2225,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c if (obj) { List options; obj->get_argument_options(p_method, p_argidx, &options); - for (String &F : options) { + for (const String &F : options) { ScriptCodeCompletionOption option(F, ScriptCodeCompletionOption::KIND_FUNCTION); r_result.insert(option.display, option); } @@ -2247,7 +2247,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { String s = E.name; if (!s.begins_with("autoload/")) { continue; @@ -2263,7 +2263,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c // Get input actions List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { String s = E.name; if (!s.begins_with("input/")) { continue; @@ -2288,7 +2288,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List methods; base.get_method_list(&methods); - for (MethodInfo &E : methods) { + for (const MethodInfo &E : methods) { if (E.name == p_method) { r_arghint = _make_arguments_hint(E, p_argidx); return; @@ -2337,7 +2337,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); int i = 0; - for (MethodInfo &E : constructors) { + for (const MethodInfo &E : constructors) { if (p_argidx >= E.arguments.size()) { continue; } @@ -2603,7 +2603,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List virtual_methods; ClassDB::get_virtual_methods(class_name, &virtual_methods); - for (MethodInfo &mi : virtual_methods) { + for (const MethodInfo &mi : virtual_methods) { String method_hint = mi.name; if (method_hint.find(":") != -1) { method_hint = method_hint.get_slice(":", 0); @@ -2652,7 +2652,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c List opts; p_owner->get_argument_options("get_node", 0, &opts); - for (String &E : opts) { + for (const String &E : opts) { String opt = E.strip_edges(); if (opt.is_quoted()) { r_forced = true; @@ -2837,7 +2837,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List virtual_methods; ClassDB::get_virtual_methods(class_name, &virtual_methods, true); - for (MethodInfo &E : virtual_methods) { + for (const MethodInfo &E : virtual_methods) { if (E.name == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; r_result.class_name = base_type.native_type; @@ -2856,7 +2856,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co List constants; ClassDB::get_integer_constant_list(class_name, &constants, true); - for (String &E : constants) { + for (const String &E : constants) { if (E == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; r_result.class_name = base_type.native_type; diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 9949d0db565..466ddb4b10a 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1332,7 +1332,7 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali } void GDScriptParser::clear_unused_annotations() { - for (AnnotationNode *annotation : annotation_stack) { + for (const AnnotationNode *annotation : annotation_stack) { push_error(vformat(R"(Annotation "%s" does not precedes a valid target, so it will have no effect.)", annotation->name), annotation); } @@ -1795,7 +1795,7 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() { List binds; branch->patterns[0]->binds.get_key_list(&binds); - for (StringName &E : binds) { + for (const StringName &E : binds) { SuiteNode::Local local(branch->patterns[0]->binds[E], current_function); suite->add_local(local); } @@ -3617,7 +3617,7 @@ void GDScriptParser::TreePrinter::push_text(const String &p_text) { printed += p_text; } -void GDScriptParser::TreePrinter::print_annotation(AnnotationNode *p_annotation) { +void GDScriptParser::TreePrinter::print_annotation(const AnnotationNode *p_annotation) { push_text(p_annotation->name); push_text(" ("); for (int i = 0; i < p_annotation->arguments.size(); i++) { @@ -3992,7 +3992,7 @@ void GDScriptParser::TreePrinter::print_for(ForNode *p_for) { } void GDScriptParser::TreePrinter::print_function(FunctionNode *p_function, const String &p_context) { - for (AnnotationNode *E : p_function->annotations) { + for (const AnnotationNode *E : p_function->annotations) { print_annotation(E); } push_text(p_context); @@ -4332,7 +4332,7 @@ void GDScriptParser::TreePrinter::print_unary_op(UnaryOpNode *p_unary_op) { } void GDScriptParser::TreePrinter::print_variable(VariableNode *p_variable) { - for (AnnotationNode *E : p_variable->annotations) { + for (const AnnotationNode *E : p_variable->annotations) { print_annotation(E); } diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 043d87c705d..6a227a55e57 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1431,7 +1431,7 @@ public: void push_line(const String &p_line = String()); void push_text(const String &p_text); - void print_annotation(AnnotationNode *p_annotation); + void print_annotation(const AnnotationNode *p_annotation); void print_array(ArrayNode *p_array); void print_assert(AssertNode *p_assert); void print_assignment(AssignmentNode *p_assignment); diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index eb68e388403..b3469ec47c8 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -465,7 +465,7 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) { } String doc; - for (String &E : doc_lines) { + for (const String &E : doc_lines) { doc += E + "\n"; } return doc; diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index eb604338598..e6c819b22f3 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -119,7 +119,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_ void GDScriptWorkspace::reload_all_workspace_scripts() { List paths; list_script_files("res://", paths); - for (String &path : paths) { + for (const String &path : paths) { Error err; String content = FileAccess::get_file_as_string(path, &err); ERR_CONTINUE(err != OK); @@ -586,7 +586,7 @@ Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(text_pos, symbols); } - for (const lsp::DocumentSymbol *symbol : symbols) { + for (const lsp::DocumentSymbol *const &symbol : symbols) { if (symbol->kind == lsp::SymbolKind::Method || symbol->kind == lsp::SymbolKind::Function) { lsp::SignatureInformation signature_info; signature_info.label = symbol->detail; diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index ca461566d30..fea513c8203 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -519,7 +519,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) { RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); int idx = 0; - for (Pair &F : E->get()) { + for (const Pair &F : E->get()) { RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F.first); #ifdef TOOLS_ENABLED diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 9530122e044..989c2d295c2 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -497,7 +497,7 @@ void GridMapEditor::_fill_selection() { } void GridMapEditor::_clear_clipboard_data() { - for (ClipboardItem &E : clipboard_items) { + for (const ClipboardItem &E : clipboard_items) { RenderingServer::get_singleton()->free(E.instance); } @@ -552,7 +552,7 @@ void GridMapEditor::_update_paste_indicator() { RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf); - for (ClipboardItem &item : clipboard_items) { + for (const ClipboardItem &item : clipboard_items) { xf = Transform3D(); xf.origin = (paste_indicator.begin + (paste_indicator.current - paste_indicator.click) + center) * node->get_cell_size(); xf.basis = rot * xf.basis; @@ -576,7 +576,7 @@ void GridMapEditor::_do_paste() { Vector3 ofs = paste_indicator.current - paste_indicator.click; undo_redo->create_action(TTR("GridMap Paste Selection")); - for (ClipboardItem &item : clipboard_items) { + for (const ClipboardItem &item : clipboard_items) { Vector3 position = rot.xform(item.grid_offset) + paste_indicator.begin + ofs; Basis orm; @@ -659,7 +659,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Refget_button_index() == MOUSE_BUTTON_RIGHT && input_action == INPUT_ERASE) || (mb->get_button_index() == MOUSE_BUTTON_LEFT && input_action == INPUT_PAINT)) { if (set_items.size()) { undo_redo->create_action(TTR("GridMap Paint")); - for (SetItem &si : set_items) { + for (const SetItem &si : set_items) { undo_redo->add_do_method(node, "set_cell_item", si.position, si.new_value, si.new_orientation); } for (List::Element *E = set_items.back(); E; E = E->prev()) { diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index 01d0e135158..0da06131aff 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -50,7 +50,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { ClassDB::ClassInfo *t = ClassDB::classes.getptr(E); ERR_FAIL_COND(!t); if (t->api != p_api || !t->exposed) { @@ -84,7 +84,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array methods; - for (StringName &F : snames) { + for (const StringName &F : snames) { Dictionary method_dict; methods.push_back(method_dict); @@ -141,7 +141,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array constants; - for (StringName &F : snames) { + for (const StringName &F : snames) { Dictionary constant_dict; constants.push_back(constant_dict); @@ -168,7 +168,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array signals; - for (StringName &F : snames) { + for (const StringName &F : snames) { Dictionary signal_dict; signals.push_back(signal_dict); @@ -203,7 +203,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array properties; - for (StringName &F : snames) { + for (const StringName &F : snames) { Dictionary property_dict; properties.push_back(property_dict); @@ -222,7 +222,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { Array property_list; //property list - for (PropertyInfo &F : t->property_list) { + for (const PropertyInfo &F : t->property_list) { Dictionary property_dict; property_list.push_back(property_dict); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 0eea0f543b8..b52277974f2 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1731,7 +1731,7 @@ void CSharpInstance::get_properties_state_for_reloading(List pinfo; get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { Pair state_pair; state_pair.first = E.name; @@ -2313,7 +2313,7 @@ void CSharpScript::_update_exports_values(Map &values, List values[E->key()] = E->get(); } - for (PropertyInfo &E : exported_members_cache) { + for (const PropertyInfo &E : exported_members_cache) { propnames.push_back(E); } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 6ae7c88213a..6ea0b56908c 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -682,7 +682,7 @@ int BindingsGenerator::_determine_enum_prefix(const EnumInterface &p_ienum) { void BindingsGenerator::_apply_prefix_to_enum_constants(BindingsGenerator::EnumInterface &p_ienum, int p_prefix_length) { if (p_prefix_length > 0) { - for (ConstantInterface &E : p_ienum.constants) { + for (const ConstantInterface &E : p_ienum.constants) { int curr_prefix_length = p_prefix_length; ConstantInterface &curr_const = E; @@ -890,7 +890,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { // Enums - for (EnumInterface &ienum : global_enums) { + for (const EnumInterface &ienum : global_enums) { CRASH_COND(ienum.constants.is_empty()); String enum_proxy_name = ienum.cname.operator String(); @@ -2668,7 +2668,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::get_method_list(type_cname, &method_list, true); method_list.sort(); - for (MethodInfo &E : method_list) { + for (const MethodInfo &E : method_list) { const MethodInfo &method_info = E; int argc = method_info.arguments.size(); @@ -3523,7 +3523,7 @@ void BindingsGenerator::_populate_global_constants() { } } - for (EnumInterface &ienum : global_enums) { + for (const EnumInterface &ienum : global_enums) { TypeInterface enum_itype; enum_itype.is_enum = true; enum_itype.name = ienum.cname.operator String(); @@ -3553,7 +3553,7 @@ void BindingsGenerator::_populate_global_constants() { hardcoded_enums.push_back("Vector2i.Axis"); hardcoded_enums.push_back("Vector3.Axis"); hardcoded_enums.push_back("Vector3i.Axis"); - for (StringName &E : hardcoded_enums) { + for (const StringName &E : hardcoded_enums) { // These enums are not generated and must be written manually (e.g.: Vector3.Axis) // Here, we assume core types do not begin with underscore TypeInterface enum_itype; diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index 308c15e7c93..fa7d418844d 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -109,7 +109,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List project_props; ProjectSettings::get_singleton()->get_property_list(&project_props); - for (PropertyInfo &prop : project_props) { + for (const PropertyInfo &prop : project_props) { if (!prop.name.begins_with("input/")) { continue; } @@ -185,7 +185,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr ClassDB::get_signal_list(native, &signals, /* p_no_inheritance: */ false); } - for (MethodInfo &E : signals) { + for (const MethodInfo &E : signals) { const String &signal = E.name; suggestions.push_back(quoted(signal)); } @@ -197,7 +197,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List sn; Theme::get_default()->get_color_list(base->get_class(), &sn); - for (StringName &E : sn) { + for (const StringName &E : sn) { suggestions.push_back(quoted(E)); } } @@ -209,7 +209,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List sn; Theme::get_default()->get_constant_list(base->get_class(), &sn); - for (StringName &E : sn) { + for (const StringName &E : sn) { suggestions.push_back(quoted(E)); } } @@ -221,7 +221,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List sn; Theme::get_default()->get_font_list(base->get_class(), &sn); - for (StringName &E : sn) { + for (const StringName &E : sn) { suggestions.push_back(quoted(E)); } } @@ -233,7 +233,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List sn; Theme::get_default()->get_font_size_list(base->get_class(), &sn); - for (StringName &E : sn) { + for (const StringName &E : sn) { suggestions.push_back(quoted(E)); } } @@ -245,7 +245,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr List sn; Theme::get_default()->get_stylebox_list(base->get_class(), &sn); - for (StringName &E : sn) { + for (const StringName &E : sn) { suggestions.push_back(quoted(E)); } } diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 358e3907848..a99dff8432b 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -177,7 +177,7 @@ MonoArray *godot_icall_DynamicGodotObject_SetMemberList(Object *p_ptr) { MonoArray *result = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), property_list.size()); int i = 0; - for (PropertyInfo &E : property_list) { + for (const PropertyInfo &E : property_list) { MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E.name); mono_array_setref(result, i, boxed); i++; diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index d7c58500054..299344bb930 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -100,7 +100,7 @@ void gd_mono_setup_runtime_main_args() { main_args.write[0] = execpath.ptrw(); int i = 1; - for (String &E : cmdline_args) { + for (const String &E : cmdline_args) { CharString &stored = cmdline_args_utf8.push_back(E.utf8())->get(); main_args.write[i] = stored.ptrw(); i++; diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 6493464759c..fa4888f8433 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -927,13 +927,13 @@ void TextServerAdvanced::font_set_oversampling(float p_oversampling) { oversampling = p_oversampling; List fonts; font_owner.get_owned_list(&fonts); - for (RID E : fonts) { + for (const RID &E : fonts) { font_owner.getornull(E)->clear_cache(); } List text_bufs; shaped_owner.get_owned_list(&text_bufs); - for (RID E : text_bufs) { + for (const RID &E : text_bufs) { invalidate(shaped_owner.getornull(E)); } } diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index cc90dfb4b81..004cbc2bb3a 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -473,7 +473,7 @@ void TextServerFallback::font_set_oversampling(float p_oversampling) { oversampling = p_oversampling; List fonts; font_owner.get_owned_list(&fonts); - for (RID E : fonts) { + for (const RID &E : fonts) { font_owner.getornull(E)->clear_cache(); } } diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 58285291033..7a2404fd809 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -752,7 +752,7 @@ void VisualScript::_update_placeholders() { List keys; variables.get_key_list(&keys); - for (StringName &E : keys) { + for (const StringName &E : keys) { if (!variables[E]._export) { continue; } @@ -874,7 +874,7 @@ void VisualScript::get_script_method_list(List *p_list) const { List funcs; functions.get_key_list(&funcs); - for (StringName &E : funcs) { + for (const StringName &E : funcs) { MethodInfo mi; mi.name = E; if (functions[E].func_id >= 0) { @@ -928,7 +928,7 @@ void VisualScript::get_script_property_list(List *p_list) const { List vars; get_variable_list(&vars); - for (StringName &E : vars) { + for (const StringName &E : vars) { //if (!variables[E]._export) // continue; PropertyInfo pi = variables[E].info; @@ -2467,7 +2467,7 @@ void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List vars; vs->get_variable_list(&vars); - for (StringName &E : vars) { + for (const StringName &E : vars) { Variant v; if (_call_stack[l].instance->get_variable(E, &v)) { p_members->push_back("variables/" + E); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 16313d58d0b..00dba117fb9 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -561,7 +561,7 @@ void VisualScriptEditor::_update_graph_connections() { List sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (VisualScript::SequenceConnection &E : sequence_conns) { + for (const VisualScript::SequenceConnection &E : sequence_conns) { graph->connect_node(itos(E.from_node), E.from_output, itos(E.to_node), 0); } @@ -1045,7 +1045,7 @@ void VisualScriptEditor::_update_members() { List func_names; script->get_function_list(&func_names); func_names.sort_custom(); - for (StringName &E : func_names) { + for (const StringName &E : func_names) { TreeItem *ti = members->create_item(functions); ti->set_text(0, E); ti->set_selectable(0, true); @@ -1099,7 +1099,7 @@ void VisualScriptEditor::_update_members() { List var_names; script->get_variable_list(&var_names); - for (StringName &E : var_names) { + for (const StringName &E : var_names) { TreeItem *ti = members->create_item(variables); ti->set_text(0, E); @@ -1123,7 +1123,7 @@ void VisualScriptEditor::_update_members() { List signal_names; script->get_custom_signal_list(&signal_names); - for (StringName &E : signal_names) { + for (const StringName &E : signal_names) { TreeItem *ti = members->create_item(_signals); ti->set_text(0, E); ti->set_selectable(0, true); @@ -1705,7 +1705,7 @@ void VisualScriptEditor::_on_nodes_delete() { List sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (VisualScript::SequenceConnection &E : sequence_conns) { + for (const VisualScript::SequenceConnection &E : sequence_conns) { if (E.from_node == cr_node || E.to_node == cr_node) { undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node); } @@ -1714,7 +1714,7 @@ void VisualScriptEditor::_on_nodes_delete() { List data_conns; script->get_data_connection_list(&data_conns); - for (VisualScript::DataConnection &E : data_conns) { + for (const VisualScript::DataConnection &E : data_conns) { if (E.from_node == F || E.to_node == F) { undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port); } @@ -1765,7 +1765,7 @@ void VisualScriptEditor::_on_nodes_duplicate() { List seqs; script->get_sequence_connection_list(&seqs); - for (VisualScript::SequenceConnection &E : seqs) { + for (const VisualScript::SequenceConnection &E : seqs) { if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) { undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]); } @@ -1773,7 +1773,7 @@ void VisualScriptEditor::_on_nodes_duplicate() { List data; script->get_data_connection_list(&data); - for (VisualScript::DataConnection &E : data) { + for (const VisualScript::DataConnection &E : data) { if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) { undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port); } @@ -2552,7 +2552,7 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) { List functions; script->get_function_list(&functions); - for (StringName &E : functions) { + for (const StringName &E : functions) { if (script->has_node(p_line)) { _update_graph(); _update_members(); @@ -2773,7 +2773,7 @@ void VisualScriptEditor::_remove_node(int p_id) { List sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (VisualScript::SequenceConnection &E : sequence_conns) { + for (const VisualScript::SequenceConnection &E : sequence_conns) { if (E.from_node == p_id || E.to_node == p_id) { undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node); } @@ -2782,7 +2782,7 @@ void VisualScriptEditor::_remove_node(int p_id) { List data_conns; script->get_data_connection_list(&data_conns); - for (VisualScript::DataConnection &E : data_conns) { + for (const VisualScript::DataConnection &E : data_conns) { if (E.from_node == p_id || E.to_node == p_id) { undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port); } @@ -2802,7 +2802,7 @@ bool VisualScriptEditor::node_has_sequence_connections(int p_id) { List sequence_conns; script->get_sequence_connection_list(&sequence_conns); - for (VisualScript::SequenceConnection &E : sequence_conns) { + for (const VisualScript::SequenceConnection &E : sequence_conns) { int from = E.from_node; int to = E.to_node; @@ -3460,7 +3460,7 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons List methods; bool found = false; ClassDB::get_virtual_methods(script->get_instance_base_type(), &methods); - for (MethodInfo &E : methods) { + for (const MethodInfo &E : methods) { if (E.name == name) { minfo = E; found = true; @@ -3732,7 +3732,7 @@ void VisualScriptEditor::_menu_option(int p_what) { _update_graph(); - for (String &E : reselect) { + for (const String &E : reselect) { GraphNode *gn = Object::cast_to(graph->get_node(E)); gn->set_selected(true); } @@ -3772,7 +3772,7 @@ void VisualScriptEditor::_menu_option(int p_what) { List sequence_connections; script->get_sequence_connection_list(&sequence_connections); - for (VisualScript::SequenceConnection &E : sequence_connections) { + for (const VisualScript::SequenceConnection &E : sequence_connections) { if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) { clipboard->sequence_connections.insert(E); } @@ -3781,7 +3781,7 @@ void VisualScriptEditor::_menu_option(int p_what) { List data_connections; script->get_data_connection_list(&data_connections); - for (VisualScript::DataConnection &E : data_connections) { + for (const VisualScript::DataConnection &E : data_connections) { if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) { clipboard->data_connections.insert(E); } @@ -3933,7 +3933,7 @@ void VisualScriptEditor::_menu_option(int p_what) { // Pick the node with input sequence. Set nodes_from; Set nodes_to; - for (VisualScript::SequenceConnection &E : seqs) { + for (const VisualScript::SequenceConnection &E : seqs) { if (nodes.has(E.from_node) && nodes.has(E.to_node)) { seqmove.insert(E); nodes_from.insert(E.from_node); @@ -3976,7 +3976,7 @@ void VisualScriptEditor::_menu_option(int p_what) { { List dats; script->get_data_connection_list(&dats); - for (VisualScript::DataConnection &E : dats) { + for (const VisualScript::DataConnection &E : dats) { if (nodes.has(E.from_node) && nodes.has(E.to_node)) { datamove.insert(E); } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) { diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index ddf61690150..62a4f465cb4 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -852,7 +852,7 @@ void VisualScriptTypeCast::_bind_methods() { } String script_ext_hint; - for (String &E : script_extensions) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index c694d6b8e06..6ba5ad4fd60 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -538,7 +538,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const Engine::get_singleton()->get_singletons(&names); property.hint = PROPERTY_HINT_ENUM; String sl; - for (Engine::Singleton &E : names) { + for (const Engine::Singleton &E : names) { if (sl != String()) { sl += ","; } @@ -683,7 +683,7 @@ void VisualScriptFunctionCall::_bind_methods() { } String script_ext_hint; - for (String &E : script_extensions) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } @@ -1004,7 +1004,7 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const List props; ClassDB::get_property_list(_get_base_type(), &props, false); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (E.name == property) { String detail_prop_name = property; if (index != StringName()) { @@ -1135,7 +1135,7 @@ void VisualScriptPropertySet::_update_cache() { List pinfo; v.get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.name == property) { type_cache = E; } @@ -1186,7 +1186,7 @@ void VisualScriptPropertySet::_update_cache() { script->get_script_property_list(&pinfo); } - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.name == property) { type_cache = E; return; @@ -1354,7 +1354,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { List plist; v.get_property_list(&plist); String options = ""; - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { options += "," + E.name; } @@ -1410,7 +1410,7 @@ void VisualScriptPropertySet::_bind_methods() { } String script_ext_hint; - for (String &E : script_extensions) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } @@ -1820,7 +1820,7 @@ void VisualScriptPropertyGet::_update_cache() { List pinfo; v.get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.name == property) { type_cache = E.type; return; @@ -2059,7 +2059,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { List plist; v.get_property_list(&plist); String options = ""; - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { options += "," + E.name; } @@ -2112,7 +2112,7 @@ void VisualScriptPropertyGet::_bind_methods() { } String script_ext_hint; - for (String &E : script_extensions) { + for (const String &E : script_extensions) { if (script_ext_hint != String()) { script_ext_hint += ","; } @@ -2323,7 +2323,7 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { } String ml; - for (StringName &E : sigs) { + for (const StringName &E : sigs) { if (ml != String()) { ml += ","; } @@ -2418,7 +2418,7 @@ void register_visual_script_func_nodes() { List ml; vt.get_method_list(&ml); - for (MethodInfo &E : ml) { + for (const MethodInfo &E : ml) { VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E.name, create_basic_type_call_node); } } diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index e6511792aa6..c517d89aa58 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1306,7 +1306,7 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const { vs->get_variable_list(&vars); String vhint; - for (StringName &E : vars) { + for (const StringName &E : vars) { if (vhint != String()) { vhint += ","; } @@ -1416,7 +1416,7 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const { vs->get_variable_list(&vars); String vhint; - for (StringName &E : vars) { + for (const StringName &E : vars) { if (vhint != String()) { vhint += ","; } @@ -1944,7 +1944,7 @@ void VisualScriptClassConstant::set_base_type(const StringName &p_which) { ClassDB::get_integer_constant_list(base_type, &constants, true); if (constants.size() > 0) { bool found_name = false; - for (String &E : constants) { + for (const String &E : constants) { if (E == name) { found_name = true; break; @@ -1993,7 +1993,7 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const ClassDB::get_integer_constant_list(base_type, &constants, true); property.hint_string = ""; - for (String &E : constants) { + for (const String &E : constants) { if (property.hint_string != String()) { property.hint_string += ","; } @@ -2078,7 +2078,7 @@ void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) { Variant::get_constants_for_type(type, &constants); if (constants.size() > 0) { bool found_name = false; - for (StringName &E : constants) { + for (const StringName &E : constants) { if (E == name) { found_name = true; break; @@ -2131,7 +2131,7 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c return; } property.hint_string = ""; - for (StringName &E : constants) { + for (const StringName &E : constants) { if (property.hint_string != String()) { property.hint_string += ","; } @@ -2358,7 +2358,7 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con Engine::get_singleton()->get_singletons(&singletons); - for (Engine::Singleton &E : singletons) { + for (const Engine::Singleton &E : singletons) { if (E.name == "VS" || E.name == "PS" || E.name == "PS2D" || E.name == "AS" || E.name == "TS" || E.name == "SS" || E.name == "SS2D") { continue; //skip these, too simple named } @@ -3749,7 +3749,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const { ProjectSettings::get_singleton()->get_property_list(&pinfo); Vector al; - for (PropertyInfo &pi : pinfo) { + for (const PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } @@ -3842,7 +3842,7 @@ void VisualScriptDeconstruct::_update_elements() { List pinfo; v.get_property_list(&pinfo); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { Element e; e.name = E.name; e.type = E.type; @@ -4023,7 +4023,7 @@ void register_visual_script_nodes() { List constructors; Variant::get_constructor_list(Variant::Type(i), &constructors); - for (MethodInfo &E : constructors) { + for (const MethodInfo &E : constructors) { if (E.arguments.size() > 0) { String name = "functions/constructors/" + Variant::get_type_name(Variant::Type(i)) + "("; for (int j = 0; j < E.arguments.size(); j++) { diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 5e9ecbe615c..8bf1c6cbfa4 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -93,7 +93,7 @@ void VisualScriptPropertySelector::_update_search() { base = ClassDB::get_parent_class_nocheck(base); } - for (StringName &E : base_list) { + for (const StringName &E : base_list) { List methods; List props; TreeItem *category = nullptr; @@ -157,7 +157,7 @@ void VisualScriptPropertySelector::_update_search() { ClassDB::get_property_list(E, &props, true); } } - for (PropertyInfo &F : props) { + for (const PropertyInfo &F : props) { if (!(F.usage & PROPERTY_USAGE_EDITOR) && !(F.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { continue; } @@ -340,7 +340,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt List fnodes; VisualScriptLanguage::singleton->get_registered_node_names(&fnodes); - for (String &E : fnodes) { + for (const String &E : fnodes) { if (!E.begins_with(root_filter)) { continue; } diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index bf269b1d7a1..9fa49b8a1d5 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -438,7 +438,7 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { ClassDB::get_signal_list(_get_base_type(), &methods); List mstring; - for (MethodInfo &E : methods) { + for (const MethodInfo &E : methods) { if (E.name.begins_with("_")) { continue; } @@ -448,7 +448,7 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { mstring.sort(); String ml; - for (String &E : mstring) { + for (const String &E : mstring) { if (ml != String()) { ml += ","; } diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 8709acf7f11..561207c24cc 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -145,7 +145,7 @@ TypedArray PhysicsBody2D::get_collision_exceptions() { List exceptions; PhysicsServer2D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (RID body : exceptions) { + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer2D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody2D *physics_body = Object::cast_to(obj); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 4a15a1dc466..3932f3dc78a 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1596,7 +1596,7 @@ void TileMap::set_light_mask(int p_light_mask) { // Occlusion: set light mask. CanvasItem::set_light_mask(p_light_mask); for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { - for (RID F : E->get().canvas_items) { + for (const RID &F : E->get().canvas_items) { RenderingServer::get_singleton()->canvas_item_set_light_mask(F, get_light_mask()); } } @@ -1609,7 +1609,7 @@ void TileMap::set_material(const Ref &p_material) { // Update material for the whole tilemap. for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (RID F : q.canvas_items) { + for (const RID &F : q.canvas_items) { RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } @@ -1622,7 +1622,7 @@ void TileMap::set_use_parent_material(bool p_use_parent_material) { // Update use_parent_material for the whole tilemap. for (Map::Element *E = quadrant_map.front(); E; E = E->next()) { TileMapQuadrant &q = E->get(); - for (RID F : q.canvas_items) { + for (const RID &F : q.canvas_items) { RS::get_singleton()->canvas_item_set_use_parent_material(F, get_use_parent_material() || get_material().is_valid()); } } @@ -1633,7 +1633,7 @@ void TileMap::set_texture_filter(TextureFilter p_texture_filter) { CanvasItem::set_texture_filter(p_texture_filter); for (Map::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (RID E : q.canvas_items) { + for (const RID &E : q.canvas_items) { RenderingServer::get_singleton()->canvas_item_set_default_texture_filter(E, RS::CanvasItemTextureFilter(p_texture_filter)); _make_quadrant_dirty(F); } @@ -1645,7 +1645,7 @@ void TileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) { CanvasItem::set_texture_repeat(p_texture_repeat); for (Map::Element *F = quadrant_map.front(); F; F = F->next()) { TileMapQuadrant &q = F->get(); - for (RID E : q.canvas_items) { + for (const RID &E : q.canvas_items) { RenderingServer::get_singleton()->canvas_item_set_default_texture_repeat(E, RS::CanvasItemTextureRepeat(p_texture_repeat)); _make_quadrant_dirty(F); } diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 97b562837ac..cc1b620025f 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -397,7 +397,7 @@ Ref GPUParticlesCollisionSDF::bake() { bake_step_function(0, "Finding Meshes"); } - for (PlotMesh &pm : plot_meshes) { + for (const PlotMesh &pm : plot_meshes) { for (int i = 0; i < pm.mesh->get_surface_count(); i++) { if (pm.mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; //only triangles diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 93cd088418f..9ca1d55d0b3 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -94,7 +94,7 @@ void MeshInstance3D::_get_property_list(List *p_list) const { ls.sort(); - for (String &E : ls) { + for (const String &E : ls) { p_list->push_back(PropertyInfo(Variant::FLOAT, E, PROPERTY_HINT_RANGE, "-1,1,0.00001")); } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 6736a4ec403..93ecb2cd3a8 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -78,7 +78,7 @@ TypedArray PhysicsBody3D::get_collision_exceptions() { List exceptions; PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; - for (RID body : exceptions) { + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to(obj); diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index fb5e9639c7d..9ce4c374572 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -264,7 +264,7 @@ void Skeleton3D::_notification(int p_what) { b.global_pose_override_amount = 0.0; } - for (ObjectID &E : b.nodes_bound) { + for (const ObjectID &E : b.nodes_bound) { Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE(!obj); Node3D *node_3d = Object::cast_to(obj); diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 0d00d10d321..a7ff0842d25 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -592,7 +592,7 @@ Array SoftBody3D::get_collision_exceptions() { List exceptions; PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); Array ret; - for (RID body : exceptions) { + for (const RID &body : exceptions) { ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to(obj); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 495f60d4c9d..4bddae3b149 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -1089,7 +1089,7 @@ bool AnimationNodeBlendTree::_get(const StringName &p_name, Variant &r_ret) cons conns.resize(nc.size() * 3); int idx = 0; - for (NodeConnection &E : nc) { + for (const NodeConnection &E : nc) { conns[idx * 3 + 0] = E.input_node; conns[idx * 3 + 1] = E.input_index; conns[idx * 3 + 2] = E.output_node; @@ -1110,7 +1110,7 @@ void AnimationNodeBlendTree::_get_property_list(List *p_list) cons } names.sort_custom(); - for (StringName &E : names) { + for (const StringName &E : names) { String name = E; if (name != "output") { p_list->push_back(PropertyInfo(Variant::OBJECT, "nodes/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 383d92d37f0..bf53b554bf1 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -512,7 +512,7 @@ void AnimationNodeStateMachine::get_parameter_list(List *r_list) c } advance_conditions.sort_custom(); - for (StringName &E : advance_conditions) { + for (const StringName &E : advance_conditions) { r_list->push_back(PropertyInfo(Variant::BOOL, E)); } } @@ -679,7 +679,7 @@ void AnimationNodeStateMachine::get_node_list(List *r_nodes) const { } nodes.sort_custom(); - for (StringName &E : nodes) { + for (const StringName &E : nodes) { r_nodes->push_back(E); } } @@ -902,7 +902,7 @@ void AnimationNodeStateMachine::_get_property_list(List *p_list) c } names.sort_custom(); - for (StringName &name : names) { + for (const StringName &name : names) { p_list->push_back(PropertyInfo(Variant::OBJECT, "states/" + name + "/node", PROPERTY_HINT_RESOURCE_TYPE, "AnimationNode", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "states/" + name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 0f557519b2a..67b6205a651 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -176,7 +176,7 @@ void AnimationPlayer::_get_property_list(List *p_list) const { anim_names.sort(); - for (PropertyInfo &E : anim_names) { + for (const PropertyInfo &E : anim_names) { p_list->push_back(E); } @@ -1076,7 +1076,7 @@ void AnimationPlayer::get_animation_list(List *p_animations) const { anims.sort(); - for (String &E : anims) { + for (const String &E : anims) { p_animations->push_back(E); } } @@ -1118,7 +1118,7 @@ void AnimationPlayer::queue(const StringName &p_name) { Vector AnimationPlayer::get_queue() { Vector ret; - for (StringName &E : queued) { + for (const StringName &E : queued) { ret.push_back(E); } @@ -1502,7 +1502,7 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i if (p_idx == 0 && (p_function == "play" || p_function == "play_backwards" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue")) { List al; get_animation_list(&al); - for (StringName &E : al) { + for (const StringName &E : al) { r_options->push_back(quote_style + String(E) + quote_style); } } diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index d277808e1f4..00b847168d1 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -76,7 +76,7 @@ void AnimationNode::get_child_nodes(List *r_child_nodes) { Dictionary cn = get_script_instance()->call("_get_child_nodes"); List keys; cn.get_key_list(&keys); - for (Variant &E : keys) { + for (const Variant &E : keys) { ChildNode child; child.name = E; child.node = cn[E]; @@ -536,7 +536,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { List sname; player->get_animation_list(&sname); - for (StringName &E : sname) { + for (const StringName &E : sname) { Ref anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); @@ -816,7 +816,7 @@ void AnimationTree::_process_graph(float p_delta) { { bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint(); - for (AnimationNode::AnimationState &as : state.animation_states) { + for (const AnimationNode::AnimationState &as : state.animation_states) { Ref a = as.animation; float time = as.time; float delta = as.delta; @@ -1369,7 +1369,7 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref children; node->get_child_nodes(&children); - for (AnimationNode::ChildNode &E : children) { + for (const AnimationNode::ChildNode &E : children) { _update_properties_for_node(p_base_path + E.name + "/", E.node); } } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 5012aed99aa..ce2b320c966 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -292,7 +292,7 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { // Add base object properties. List pinfo; obj->get_property_list(&pinfo, true); - for (PropertyInfo &E : pinfo) { + for (const PropertyInfo &E : pinfo) { if (E.usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) { properties.push_back(SceneDebuggerProperty(E, obj->get(E.name))); } @@ -452,7 +452,7 @@ SceneDebuggerTree::SceneDebuggerTree(Node *p_root) { } void SceneDebuggerTree::serialize(Array &p_arr) { - for (RemoteNode &n : nodes) { + for (const RemoteNode &n : nodes) { p_arr.push_back(n.child_count); p_arr.push_back(n.name); p_arr.push_back(n.type_name); diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 6e3d0e2767a..17fe8f4dca1 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -2288,7 +2288,7 @@ void CodeEdit::_filter_code_completion_candidates() { TypedArray completion_options_sources; completion_options_sources.resize(code_completion_option_sources.size()); int i = 0; - for (ScriptCodeCompletionOption &E : code_completion_option_sources) { + for (const ScriptCodeCompletionOption &E : code_completion_option_sources) { Dictionary option; option["kind"] = E.kind; option["display_text"] = E.display; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index ae1f4b2f653..e3bfb2b40cd 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -343,7 +343,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_icon_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.icon_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -355,7 +355,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_stylebox_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.style_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -367,7 +367,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_font_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.font_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -379,7 +379,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_font_size_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.font_size_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -391,7 +391,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_color_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.color_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -403,7 +403,7 @@ void Control::_get_property_list(List *p_list) const { { List names; theme->get_constant_list(get_class_name(), &names); - for (StringName &E : names) { + for (const StringName &E : names) { uint32_t usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE; if (data.constant_override.has(E)) { usage |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; @@ -428,7 +428,7 @@ void Control::_validate_property(PropertyInfo &property) const { Vector unique_names; String hint_string; - for (StringName &E : names) { + for (const StringName &E : names) { // Skip duplicate values. if (unique_names.has(E)) { continue; @@ -793,7 +793,7 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { return theme_owner->data.theme->get_theme_item(p_data_type, p_name, E); } @@ -822,7 +822,7 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { return Theme::get_project_default()->get_theme_item(p_data_type, p_name, E); } @@ -830,7 +830,7 @@ T Control::get_theme_item_in_types(Control *p_theme_owner, Window *p_theme_owner } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { return Theme::get_default()->get_theme_item(p_data_type, p_name, E); } @@ -848,7 +848,7 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow Window *theme_owner_window = p_theme_owner_window; while (theme_owner || theme_owner_window) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (theme_owner && theme_owner->data.theme->has_theme_item(p_data_type, p_name, E)) { return true; } @@ -877,7 +877,7 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow // Secondly, check the project-defined Theme resource. if (Theme::get_project_default().is_valid()) { - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_project_default()->has_theme_item(p_data_type, p_name, E)) { return true; } @@ -885,7 +885,7 @@ bool Control::has_theme_item_in_types(Control *p_theme_owner, Window *p_theme_ow } // Lastly, fall back on the items defined in the default Theme, if they exist. - for (StringName &E : p_theme_types) { + for (const StringName &E : p_theme_types) { if (Theme::get_default()->has_theme_item(p_data_type, p_name, E)) { return true; } @@ -2580,7 +2580,7 @@ void Control::get_argument_options(const StringName &p_function, int p_idx, List } sn.sort_custom(); - for (StringName &E : sn) { + for (const StringName &E : sn) { r_options->push_back(quote_style + E + quote_style); } } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 67cb6f04a74..2e4204e1717 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -552,7 +552,7 @@ void FileDialog::update_file_list() { bool match = patterns.is_empty(); String match_str; - for (String &E : patterns) { + for (const String &E : patterns) { if (files.front()->get().matchn(E)) { match_str = E; match = true; diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 8ad4d04b7f8..1fac2b91296 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -217,7 +217,7 @@ Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const S } bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) { - for (Connection &E : connections) { + for (const Connection &E : connections) { if (E.from == p_from && E.from_port == p_from_port && E.to == p_to && E.to_port == p_to_port) { return true; } @@ -561,7 +561,7 @@ void GraphEdit::_top_layer_input(const Ref &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (valid_left_disconnect_types.has(gn->get_connection_output_type(j))) { //check disconnect - for (Connection &E : connections) { + for (const Connection &E : connections) { if (E.from == gn->get_name() && E.from_port == j) { Node *to = get_node(String(E.to)); if (Object::cast_to(to)) { @@ -603,7 +603,7 @@ void GraphEdit::_top_layer_input(const Ref &p_ev) { if (is_in_hot_zone(pos / zoom, click_pos)) { if (right_disconnects || valid_right_disconnect_types.has(gn->get_connection_input_type(j))) { //check disconnect - for (Connection &E : connections) { + for (const Connection &E : connections) { if (E.to == gn->get_name() && E.to_port == j) { Node *fr = get_node(String(E.from)); if (Object::cast_to(fr)) { @@ -1001,7 +1001,7 @@ void GraphEdit::_minimap_draw() { // Draw node connections. Color activity_color = get_theme_color(SNAME("activity")); - for (Connection &E : connections) { + for (const Connection &E : connections) { NodePath fromnp(E.from); Node *from = get_node(fromnp); @@ -1500,7 +1500,7 @@ Array GraphEdit::_get_connection_list() const { List conns; get_connection_list(&conns); Array arr; - for (Connection &E : conns) { + for (const Connection &E : conns) { Dictionary d; d["from"] = E.from; d["from_port"] = E.from_port; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index ae3db4a983c..7790a0970ca 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -397,7 +397,7 @@ void PopupMenu::_gui_input(const Ref &p_event) { Ref m = p_event; if (m.is_valid()) { - for (Rect2 &E : autohide_areas) { + for (const Rect2 &E : autohide_areas) { if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E.has_point(m->get_position())) { _close_pressed(); return; @@ -751,7 +751,7 @@ void PopupMenu::_notification(int p_what) { Point2 mouse_pos = DisplayServer::get_singleton()->mouse_get_position(); mouse_pos -= get_position(); - for (Rect2 &E : autohide_areas) { + for (const Rect2 &E : autohide_areas) { if (!Rect2(Point2(), get_size()).has_point(mouse_pos) && E.has_point(mouse_pos)) { _close_pressed(); return; diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 588d4b67d57..2c6cefa7715 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -220,7 +220,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) { client->get_response_headers(&rheaders); response_headers.resize(0); downloaded.set(0); - for (String &E : rheaders) { + for (const String &E : rheaders) { response_headers.push_back(E); } @@ -235,7 +235,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) { String new_request; - for (String &E : rheaders) { + for (const String &E : rheaders) { if (E.findn("Location: ") != -1) { new_request = E.substr(9, E.length()).strip_edges(); } diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index b7c6723cfcb..b5ba1899ec2 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -95,7 +95,7 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Refset_name(get_name()); int pos = get_index(); - for (PropSet &E : stored_values) { + for (const PropSet &E : stored_values) { scene->set(E.name, E.value); } @@ -114,7 +114,7 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) { Dictionary ret; PackedStringArray order; - for (PropSet &E : stored_values) { + for (const PropSet &E : stored_values) { ret[E.name] = E.value; if (p_with_order) { order.push_back(E.name); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 4b496d4761b..f1e55743519 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1597,7 +1597,7 @@ Array Node::_get_groups() const { Array groups; List gi; get_groups(&gi); - for (GroupInfo &E : gi) { + for (const GroupInfo &E : gi) { groups.push_back(E.name); } @@ -1947,7 +1947,7 @@ Node *Node::_duplicate(int p_flags, Map *r_duplimap) const List plist; N->get()->get_property_list(&plist); - for (PropertyInfo &E : plist) { + for (const PropertyInfo &E : plist) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -1983,7 +1983,7 @@ Node *Node::_duplicate(int p_flags, Map *r_duplimap) const if (p_flags & DUPLICATE_GROUPS) { List gi; get_groups(&gi); - for (GroupInfo &E : gi) { + for (const GroupInfo &E : gi) { #ifdef TOOLS_ENABLED if ((p_flags & DUPLICATE_FROM_EDITOR) && !E.persistent) { continue; @@ -2073,7 +2073,7 @@ void Node::remap_node_resources(Node *p_node, const Map &p_resource_re List props; p_node->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -2099,7 +2099,7 @@ void Node::remap_nested_resources(RES p_resource, const Map &p_resourc List props; p_resource->get_property_list(&props); - for (PropertyInfo &E : props) { + for (const PropertyInfo &E : props) { if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } @@ -2135,7 +2135,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { List conns; n->get_all_signal_connections(&conns); - for (Connection &E : conns) { + for (const Connection &E : conns) { if (E.flags & CONNECT_PERSIST) { //user connected NodePath p = p_original->get_path_to(n); @@ -2194,7 +2194,7 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) { List groups; get_groups(&groups); - for (GroupInfo &E : groups) { + for (const GroupInfo &E : groups) { p_node->add_to_group(E.name, E.persistent); } } @@ -2241,7 +2241,7 @@ void Node::_replace_connections_target(Node *p_new_target) { List cl; get_signals_connected_to_this(&cl); - for (Connection &c : cl) { + for (const Connection &c : cl) { if (c.flags & CONNECT_PERSIST) { c.signal.get_object()->disconnect(c.signal.get_name(), Callable(this, c.callable.get_method())); bool valid = p_new_target->has_method(c.callable.get_method()) || Ref