diff --git a/core/config/engine.cpp b/core/config/engine.cpp index ad31966a65c..c03c872f17a 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -214,8 +214,8 @@ bool Engine::has_singleton(const String &p_name) const { } void Engine::get_singletons(List *p_singletons) { - for (List::Element *E = singletons.front(); E; E = E->next()) { - p_singletons->push_back(E->get()); + for (Singleton &E : singletons) { + p_singletons->push_back(E); } } diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 84860b648d2..22acb23bce6 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -700,9 +700,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map>::Element *E = props.front(); E; E = E->next()) { - for (List::Element *F = E->get().front(); F; F = F->next()) { - count++; - } + count += E->get().size(); } if (p_custom_features != String()) { @@ -734,8 +732,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map>::Element *E = props.front(); E; E = E->next()) { - for (List::Element *F = E->get().front(); F; F = F->next()) { - String key = F->get(); + for (String &key : E->get()) { if (E->key() != "") { key = E->key() + "/" + key; } @@ -803,8 +800,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapkey() != "") { file->store_string("[" + E->key() + "]\n\n"); } - for (List::Element *F = E->get().front(); F; F = F->next()) { - String key = F->get(); + for (String &F : E->get()) { + String key = F; if (E->key() != "") { key = E->key() + "/" + key; } @@ -817,7 +814,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Mapstore_string(F->get().property_name_encode() + "=" + vstr + "\n"); + file->store_string(F.property_name_encode() + "=" + vstr + "\n"); } } @@ -931,11 +928,11 @@ Vector ProjectSettings::get_optimizer_presets() const { ProjectSettings::get_singleton()->get_property_list(&pi); Vector names; - for (List::Element *E = pi.front(); E; E = E->next()) { - if (!E->get().name.begins_with("optimizer_presets/")) { + for (PropertyInfo &E : pi) { + if (!E.name.begins_with("optimizer_presets/")) { continue; } - names.push_back(E->get().name.get_slicec('/', 1)); + names.push_back(E.name.get_slicec('/', 1)); } names.sort(); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 8ec934db62a..7a1ba632336 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -75,8 +75,8 @@ Vector _ResourceLoader::get_recognized_extensions_for_type(const String List exts; ResourceLoader::get_recognized_extensions_for_type(p_type, &exts); Vector ret; - for (List::Element *E = exts.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : exts) { + ret.push_back(E); } return ret; @@ -91,8 +91,8 @@ PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); PackedStringArray ret; - for (List::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : deps) { + ret.push_back(E); } return ret; @@ -141,8 +141,8 @@ Vector _ResourceSaver::get_recognized_extensions(const RES &p_resource) List exts; ResourceSaver::get_recognized_extensions(p_resource, &exts); Vector ret; - for (List::Element *E = exts.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : exts) { + ret.push_back(E); } return ret; } @@ -268,8 +268,8 @@ String _OS::get_name() const { Vector _OS::get_cmdline_args() { List cmdline = OS::get_singleton()->get_cmdline_args(); Vector cmdlinev; - for (List::Element *E = cmdline.front(); E; E = E->next()) { - cmdlinev.push_back(E->get()); + for (String &E : cmdline) { + cmdlinev.push_back(E); } return cmdlinev; @@ -355,20 +355,20 @@ void _OS::print_all_textures_by_size() { List> rsrc; ResourceCache::get_cached_resources(&rsrc); - for (List>::Element *E = rsrc.front(); E; E = E->next()) { - if (!E->get()->is_class("ImageTexture")) { + for (Ref E : rsrc) { + if (!E->is_class("ImageTexture")) { continue; } - Size2 size = E->get()->call("get_size"); - int fmt = E->get()->call("get_format"); + Size2 size = E->call("get_size"); + int fmt = E->call("get_format"); _OSCoreBindImg img; img.size = size; img.fmt = fmt; - img.path = E->get()->get_path(); + img.path = E->get_path(); img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt)); - img.id = E->get()->get_instance_id(); + img.id = E->get_instance_id(); total += img.vram; imgs.push_back(img); } @@ -376,8 +376,8 @@ void _OS::print_all_textures_by_size() { imgs.sort(); - for (List<_OSCoreBindImg>::Element *E = imgs.front(); E; E = E->next()) { - total -= E->get().vram; + for (_OSCoreBindImg &E : imgs) { + total -= E.vram; } } @@ -387,9 +387,7 @@ void _OS::print_resources_by_type(const Vector &p_types) { List> resources; ResourceCache::get_cached_resources(&resources); - for (List>::Element *E = resources.front(); E; E = E->next()) { - Ref r = E->get(); - + for (Ref r : resources) { bool found = false; for (int i = 0; i < p_types.size(); i++) { @@ -1824,8 +1822,8 @@ PackedStringArray _ClassDB::get_class_list() const { PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (List::Element *E = classes.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (StringName &E : classes) { + ret.set(idx++, E); } return ret; @@ -1838,8 +1836,8 @@ PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) PackedStringArray ret; ret.resize(classes.size()); int idx = 0; - for (List::Element *E = classes.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (StringName &E : classes) { + ret.set(idx++, E); } return ret; @@ -1893,8 +1891,8 @@ 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 (List::Element *E = signals.front(); E; E = E->next()) { - ret.push_back(E->get().operator Dictionary()); + for (MethodInfo &E : signals) { + ret.push_back(E.operator Dictionary()); } return ret; @@ -1904,8 +1902,8 @@ 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 (List::Element *E = plist.front(); E; E = E->next()) { - ret.push_back(E->get().operator Dictionary()); + for (PropertyInfo &E : plist) { + ret.push_back(E.operator Dictionary()); } return ret; @@ -1937,12 +1935,12 @@ 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 (List::Element *E = methods.front(); E; E = E->next()) { + for (MethodInfo &E : methods) { #ifdef DEBUG_METHODS_ENABLED - ret.push_back(E->get().operator Dictionary()); + ret.push_back(E.operator Dictionary()); #else Dictionary dict; - dict["name"] = E->get().name; + dict["name"] = E.name; ret.push_back(dict); #endif } @@ -1957,8 +1955,8 @@ PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, PackedStringArray ret; ret.resize(constants.size()); int idx = 0; - for (List::Element *E = constants.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (String &E : constants) { + ret.set(idx++, E); } return ret; diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp index 26f82c26586..b832dd58d58 100644 --- a/core/debugger/debugger_marshalls.cpp +++ b/core/debugger/debugger_marshalls.cpp @@ -40,11 +40,11 @@ Array DebuggerMarshalls::ResourceUsage::serialize() { Array arr; arr.push_back(infos.size() * 4); - for (List::Element *E = infos.front(); E; E = E->next()) { - arr.push_back(E->get().path); - arr.push_back(E->get().format); - arr.push_back(E->get().type); - arr.push_back(E->get().vram); + for (ResourceInfo &E : infos) { + arr.push_back(E.path); + arr.push_back(E.format); + arr.push_back(E.type); + arr.push_back(E.vram); } return arr; } diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index ab368471e48..24833711d5d 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -320,13 +320,13 @@ void LocalDebugger::print_variables(const List &names, const List value_lines; const List::Element *V = values.front(); - for (const List::Element *E = names.front(); E; E = E->next()) { + for (const String &E : names) { value = String(V->get()); if (variable_prefix.is_empty()) { - print_line(E->get() + ": " + String(V->get())); + print_line(E + ": " + String(V->get())); } else { - print_line(E->get() + ":"); + print_line(E + ":"); value_lines = value.split("\n"); for (int i = 0; i < value_lines.size(); ++i) { print_line(variable_prefix + value_lines[i]); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index bdbb7766fa0..7d3abc9b462 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -427,16 +427,16 @@ void RemoteDebugger::_send_resource_usage() { List tinfo; RS::get_singleton()->texture_debug_usage(&tinfo); - for (List::Element *E = tinfo.front(); E; E = E->next()) { + for (RS::TextureInfo &E : tinfo) { DebuggerMarshalls::ResourceInfo info; - info.path = E->get().path; - info.vram = E->get().bytes; - info.id = E->get().texture; + info.path = E.path; + info.vram = E.bytes; + info.id = E.texture; info.type = "Texture"; - if (E->get().depth == 0) { - info.format = itos(E->get().width) + "x" + itos(E->get().height) + " " + Image::get_format_name(E->get().format); + if (E.depth == 0) { + info.format = itos(E.width) + "x" + itos(E.height) + " " + Image::get_format_name(E.format); } else { - info.format = itos(E->get().width) + "x" + itos(E->get().height) + "x" + itos(E->get().depth) + " " + Image::get_format_name(E->get().format); + info.format = itos(E.width) + "x" + itos(E.height) + "x" + itos(E.depth) + " " + Image::get_format_name(E.format); } usage.infos.push_back(info); } diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 3c132a619dc..cc2974cbdb3 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -276,10 +276,10 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Dictionary d1; d1["name"] = E->key(); Array values; - for (List>::Element *F = E->get().front(); F; F = F->next()) { + for (Pair &F : E->get()) { Dictionary d2; - d2["name"] = F->get().first; - d2["value"] = F->get().second; + d2["name"] = F.first; + d2["value"] = F.second; values.push_back(d2); } d1["values"] = values; @@ -294,8 +294,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List utility_func_names; Variant::get_utility_function_list(&utility_func_names); - for (List::Element *E = utility_func_names.front(); E; E = E->next()) { - StringName name = E->get(); + for (StringName &name : utility_func_names) { Dictionary func; func["name"] = String(name); if (Variant::has_utility_function_return_value(name)) { @@ -363,8 +362,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List member_names; Variant::get_member_list(type, &member_names); - for (List::Element *E = member_names.front(); E; E = E->next()) { - StringName member_name = E->get(); + for (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)); @@ -380,8 +378,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List constant_names; Variant::get_constants_for_type(type, &constant_names); - for (List::Element *E = constant_names.front(); E; E = E->next()) { - StringName constant_name = E->get(); + for (StringName &constant_name : constant_names) { Dictionary d2; d2["name"] = String(constant_name); Variant constant = Variant::get_constant_value(type, constant_name); @@ -420,8 +417,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List method_names; Variant::get_builtin_method_list(type, &method_names); - for (List::Element *E = method_names.front(); E; E = E->next()) { - StringName method_name = E->get(); + for (StringName &method_name : method_names) { Dictionary d2; d2["name"] = String(method_name); if (Variant::has_builtin_method_return_value(type, method_name)) { @@ -503,9 +499,8 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { class_list.sort_custom(); - for (List::Element *E = class_list.front(); E; E = E->next()) { + for (StringName &class_name : class_list) { Dictionary d; - StringName class_name = E->get(); d["name"] = String(class_name); d["is_refcounted"] = ClassDB::is_parent_class(class_name, "RefCounted"); d["is_instantiable"] = ClassDB::can_instantiate(class_name); @@ -525,15 +520,15 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array constants; List constant_list; ClassDB::get_integer_constant_list(class_name, &constant_list, true); - for (List::Element *F = constant_list.front(); F; F = F->next()) { - StringName enum_name = ClassDB::get_integer_constant_enum(class_name, F->get()); + for (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 } Dictionary d2; - d2["name"] = String(F->get()); - d2["value"] = ClassDB::get_integer_constant(class_name, F->get()); + d2["name"] = String(F); + d2["value"] = ClassDB::get_integer_constant(class_name, F); constants.push_back(d2); } @@ -547,13 +542,13 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array enums; List enum_list; ClassDB::get_enum_list(class_name, &enum_list, true); - for (List::Element *F = enum_list.front(); F; F = F->next()) { + for (StringName &F : enum_list) { Dictionary d2; - d2["name"] = String(F->get()); + d2["name"] = String(F); Array values; List enum_constant_list; - ClassDB::get_enum_constants(class_name, F->get(), &enum_constant_list, true); + ClassDB::get_enum_constants(class_name, F, &enum_constant_list, true); for (List::Element *G = enum_constant_list.front(); G; G = G->next()) { Dictionary d3; d3["name"] = String(G->get()); @@ -575,14 +570,14 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array methods; List method_list; ClassDB::get_method_list(class_name, &method_list, true); - for (List::Element *F = method_list.front(); F; F = F->next()) { - StringName method_name = F->get().name; - if (F->get().flags & METHOD_FLAG_VIRTUAL) { + for (MethodInfo &F : method_list) { + StringName method_name = F.name; + if (F.flags & METHOD_FLAG_VIRTUAL) { //virtual method - const MethodInfo &mi = F->get(); + const MethodInfo &mi = F; Dictionary d2; d2["name"] = String(method_name); - d2["is_const"] = (F->get().flags & METHOD_FLAG_CONST) ? true : false; + d2["is_const"] = (F.flags & METHOD_FLAG_CONST) ? true : false; d2["is_vararg"] = false; d2["is_virtual"] = true; // virtual functions have no hash since no MethodBind is involved @@ -619,7 +614,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { methods.push_back(d2); - } else if (F->get().name.begins_with("_")) { + } else if (F.name.begins_with("_")) { //hidden method, ignore } else { @@ -692,19 +687,19 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array signals; List signal_list; ClassDB::get_signal_list(class_name, &signal_list, true); - for (List::Element *F = signal_list.front(); F; F = F->next()) { - StringName signal_name = F->get().name; + for (MethodInfo &F : signal_list) { + StringName signal_name = F.name; Dictionary d2; d2["name"] = String(signal_name); Array arguments; - for (int i = 0; i < F->get().arguments.size(); i++) { + for (int i = 0; i < F.arguments.size(); i++) { Dictionary d3; - d3["name"] = F->get().arguments[i].name; - Variant::Type type = F->get().arguments[i].type; - if (F->get().arguments[i].class_name != StringName()) { - d3["type"] = String(F->get().arguments[i].class_name); + d3["name"] = F.arguments[i].name; + Variant::Type type = F.arguments[i].type; + if (F.arguments[i].class_name != StringName()) { + d3["type"] = String(F.arguments[i].class_name); } else if (type == Variant::NIL) { d3["type"] = "Variant"; } else { @@ -728,28 +723,28 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { Array properties; List property_list; ClassDB::get_property_list(class_name, &property_list, true); - for (List::Element *F = property_list.front(); F; F = F->next()) { - if (F->get().usage & PROPERTY_USAGE_CATEGORY || F->get().usage & PROPERTY_USAGE_GROUP || F->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (PropertyInfo &F : property_list) { + if (F.usage & PROPERTY_USAGE_CATEGORY || F.usage & PROPERTY_USAGE_GROUP || F.usage & PROPERTY_USAGE_SUBGROUP) { continue; //not real properties } - if (F->get().name.begins_with("_")) { + if (F.name.begins_with("_")) { continue; //hidden property } - StringName property_name = F->get().name; + StringName property_name = F.name; Dictionary d2; d2["name"] = String(property_name); - if (F->get().class_name != StringName()) { - d2["type"] = String(F->get().class_name); - } else if (F->get().type == Variant::NIL && F->get().usage & PROPERTY_USAGE_NIL_IS_VARIANT) { + if (F.class_name != StringName()) { + d2["type"] = String(F.class_name); + } else if (F.type == Variant::NIL && F.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { d2["type"] = "Variant"; } else { - d2["type"] = Variant::get_type_name(F->get().type); + d2["type"] = Variant::get_type_name(F.type); } - d2["setter"] = ClassDB::get_property_setter(class_name, F->get().name); - d2["getter"] = ClassDB::get_property_getter(class_name, F->get().name); - d2["index"] = ClassDB::get_property_index(class_name, F->get().name); + d2["setter"] = ClassDB::get_property_setter(class_name, F.name); + d2["getter"] = ClassDB::get_property_getter(class_name, F.name); + d2["index"] = ClassDB::get_property_index(class_name, F.name); properties.push_back(d2); } @@ -771,8 +766,7 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() { List singleton_list; Engine::get_singleton()->get_singletons(&singleton_list); - for (List::Element *E = singleton_list.front(); E; E = E->next()) { - const Engine::Singleton &s = E->get(); + for (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 65718a75071..5f91e611025 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -351,8 +351,8 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or String library_path; - for (List::Element *E = libraries.front(); E; E = E->next()) { - Vector tags = E->get().split("."); + for (String &E : libraries) { + Vector tags = E.split("."); bool all_tags_met = true; for (int i = 0; i < tags.size(); i++) { String tag = tags[i].strip_edges(); @@ -363,7 +363,7 @@ RES NativeExtensionResourceLoader::load(const String &p_path, const String &p_or } if (all_tags_met) { - library_path = config->get_value("libraries", E->get()); + library_path = config->get_value("libraries", E); break; } } diff --git a/core/input/input.cpp b/core/input/input.cpp index 6bcf2b4777a..e30e7c814fd 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -174,9 +174,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (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 b5f067d4993..0c8705b2630 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -65,11 +65,11 @@ String InputMap::_suggest_actions(const StringName &p_action) const { float closest_similarity = 0.0; // Find the most action with the most similar name. - for (List::Element *E = actions.front(); E; E = E->next()) { - const float similarity = String(E->get()).similarity(p_action); + for (StringName &action : actions) { + const float similarity = String(action).similarity(p_action); if (similarity > closest_similarity) { - closest_action = E->get(); + closest_action = action; closest_similarity = similarity; } } @@ -105,8 +105,8 @@ Array InputMap::_get_actions() { return ret; } - for (const List::Element *E = actions.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : actions) { + ret.push_back(E); } return ret; @@ -129,13 +129,11 @@ List>::Element *InputMap::_find_event(Action &p_action, const Re ERR_FAIL_COND_V(!p_event.is_valid(), nullptr); for (List>::Element *E = p_action.inputs.front(); E; E = E->next()) { - const Ref e = E->get(); - - int device = e->get_device(); + int device = E->get()->get_device(); if (device == ALL_DEVICES || device == p_event->get_device()) { - if (p_exact_match && e->is_match(p_event, true)) { + if (p_exact_match && E->get()->is_match(p_event, true)) { return E; - } else if (!p_exact_match && e->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { + } else if (!p_exact_match && E->get()->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { return E; } } @@ -198,7 +196,7 @@ Array InputMap::_action_get_events(const StringName &p_action) { const List> *al = action_get_events(p_action); if (al) { for (const List>::Element *E = al->front(); E; E = E->next()) { - ret.push_back(E->get()); + ret.push_back(E); } } @@ -263,9 +261,7 @@ void InputMap::load_from_project_settings() { List pinfo; ProjectSettings::get_singleton()->get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (!pi.name.begins_with("input/")) { continue; } diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 10f68f3cef5..aeaf25f321a 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -40,8 +40,8 @@ PackedStringArray ConfigFile::_get_sections() const { PackedStringArray arr; arr.resize(s.size()); int idx = 0; - for (const List::Element *E = s.front(); E; E = E->next()) { - arr.set(idx++, E->get()); + for (const String &E : s) { + arr.set(idx++, E); } return arr; @@ -53,8 +53,8 @@ PackedStringArray ConfigFile::_get_section_keys(const String &p_section) const { PackedStringArray arr; arr.resize(s.size()); int idx = 0; - for (const List::Element *E = s.front(); E; E = E->next()) { - arr.set(idx++, E->get()); + for (const String &E : s) { + arr.set(idx++, E); } return arr; diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index dfba00067f3..e30a8dfdd0c 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -93,8 +93,8 @@ static Error _erase_recursive(DirAccess *da) { da->list_dir_end(); - for (List::Element *E = dirs.front(); E; E = E->next()) { - Error err = da->change_dir(E->get()); + for (String &E : dirs) { + Error err = da->change_dir(E); if (err == OK) { err = _erase_recursive(da); if (err) { @@ -105,7 +105,7 @@ static Error _erase_recursive(DirAccess *da) { if (err) { return err; } - err = da->remove(da->get_current_dir().plus_file(E->get())); + err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; } @@ -114,8 +114,8 @@ static Error _erase_recursive(DirAccess *da) { } } - for (List::Element *E = files.front(); E; E = E->next()) { - Error err = da->remove(da->get_current_dir().plus_file(E->get())); + for (String &E : files) { + Error err = da->remove(da->get_current_dir().plus_file(E)); if (err) { return err; } @@ -362,16 +362,15 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag list_dir_end(); - for (List::Element *E = dirs.front(); E; E = E->next()) { - String rel_path = E->get(); + for (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); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot create directory '" + target_dir + "'."); } - Error err = change_dir(E->get()); - ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + E->get() + "'."); + Error err = change_dir(rel_path); + ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot change current directory to '" + rel_path + "'."); err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags, p_copy_links); if (err) { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 8000dd4290c..5c1352c1b6a 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -93,8 +93,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() { List rh; get_response_headers(&rh); Dictionary ret; - for (const List::Element *E = rh.front(); E; E = E->next()) { - const String &s = E->get(); + for (const String &s : rh) { int sp = s.find(":"); if (sp == -1) { continue; @@ -113,8 +112,8 @@ PackedStringArray HTTPClient::_get_response_headers() { PackedStringArray ret; ret.resize(rh.size()); int idx = 0; - for (const List::Element *E = rh.front(); E; E = E->next()) { - ret.set(idx++, E->get()); + for (const String &E : rh) { + ret.set(idx++, E); } return ret; diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index b45e9d26b1b..b0bd328d216 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -35,8 +35,8 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { List extensions; get_recognized_extensions(&extensions); - for (List::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(p_extension) == 0) { + for (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 001b1c47574..132c69b7daf 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -252,8 +252,8 @@ Array IP::_get_local_addresses() const { Array addresses; List ip_addresses; get_local_addresses(&ip_addresses); - for (List::Element *E = ip_addresses.front(); E; E = E->next()) { - addresses.push_back(E->get()); + for (IPAddress &E : ip_addresses) { + addresses.push_back(E); } return addresses; @@ -271,8 +271,8 @@ Array IP::_get_local_interfaces() const { rc["index"] = c.index; Array ips; - for (const List::Element *F = c.ip_addresses.front(); F; F = F->next()) { - ips.push_front(F->get()); + for (const IPAddress &F : c.ip_addresses) { + ips.push_front(F); } rc["addresses"] = ips; @@ -286,8 +286,8 @@ void IP::get_local_addresses(List *r_addresses) const { Map interfaces; get_local_interfaces(&interfaces); for (Map::Element *E = interfaces.front(); E; E = E->next()) { - for (const List::Element *F = E->get().ip_addresses.front(); F; F = F->next()) { - r_addresses->push_front(F->get()); + for (const IPAddress &F : E->get().ip_addresses) { + r_addresses->push_front(F); } } } diff --git a/core/io/json.cpp b/core/io/json.cpp index b3a24982121..77a61819318 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -121,14 +121,14 @@ String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_ keys.sort(); } - for (List::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { if (E != keys.front()) { s += ","; s += end_statement; } - s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); s += colon; - s += _stringify(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _stringify(d[E], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); } s += end_statement + _make_indent(p_indent, p_cur_indent) + "}"; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index f342db2dad0..34d37dc99bd 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1358,8 +1358,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo obj->get_property_list(&props); int pc = 0; - for (List::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } pc++; @@ -1372,15 +1372,15 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; - for (List::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - _encode_string(E->get().name, buf, r_len); + _encode_string(E.name, buf, r_len); int len; - Error err = encode_variant(obj->get(E->get().name), buf, len, p_full_objects); + Error err = encode_variant(obj->get(E.name), buf, len, p_full_objects); if (err) { return err; } @@ -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 (List::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { /* CharString utf8 = E->->utf8(); @@ -1433,13 +1433,13 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len++; //pad */ int len; - encode_variant(E->get(), buf, len, p_full_objects); + encode_variant(E, buf, len, p_full_objects); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) { buf += len; } - Variant *v = d.getptr(E->get()); + Variant *v = d.getptr(E); ERR_FAIL_COND_V(!v, ERR_BUG); encode_variant(*v, buf, len, p_full_objects); ERR_FAIL_COND_V(len % 4, ERR_BUG); diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index e99c60613af..ee49335f553 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -555,12 +555,12 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC ofs += encode_cstring(path.get_data(), &packet.write[ofs]); - for (List::Element *E = peers_to_add.front(); E; E = E->next()) { - network_peer->set_target_peer(E->get()); // To all of you. + for (int &E : peers_to_add) { + network_peer->set_target_peer(E); // To all of you. network_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE); network_peer->put_packet(packet.ptr(), packet.size()); - psc->confirmed_peers.insert(E->get(), false); // Insert into confirmed, but as false since it was not confirmed. + psc->confirmed_peers.insert(E, false); // Insert into confirmed, but as false since it was not confirmed. } } @@ -917,8 +917,8 @@ 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 (List::Element *E = keys.front(); E; E = E->next()) { - PathSentCache *psc = path_send_cache.getptr(E->get()); + for (NodePath &E : keys) { + PathSentCache *psc = path_send_cache.getptr(E); psc->confirmed_peers.erase(p_id); } emit_signal(SNAME("network_peer_disconnected"), p_id); diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index cf6a0b60277..ec43ea9311d 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -268,21 +268,21 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector &tmpd d.get_key_list(&keys); List sortk; - for (List::Element *E = keys.front(); E; E = E->next()) { + for (Variant &key : keys) { DictKey dk; - dk.hash = E->get().hash(); - dk.key = E->get(); + dk.hash = key.hash(); + dk.key = key; sortk.push_back(dk); } sortk.sort(); int idx = 0; - for (List::Element *E = sortk.front(); E; E = E->next()) { - encode_uint32(E->get().hash, &tmpdata.write[pos + 8 + idx * 12 + 0]); - uint32_t ofs = _pack(E->get().key, tmpdata, string_cache); + for (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]); - ofs = _pack(d[E->get().key], tmpdata, string_cache); + ofs = _pack(d[E.key], tmpdata, string_cache); encode_uint32(ofs, &tmpdata.write[pos + 8 + idx * 12 + 8]); idx++; } diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 91a13869651..695988bd71f 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -165,15 +165,15 @@ Error Resource::copy_from(const Ref &p_resource) { List pi; p_resource->get_property_list(&pi); - for (List::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : pi) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - if (E->get().name == "resource_path") { + if (E.name == "resource_path") { continue; //do not change path } - set(E->get().name, p_resource->get(E->get().name)); + set(E.name, p_resource->get(E.name)); } return OK; } @@ -201,11 +201,11 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Maplocal_scene = p_for_scene; - for (List::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if (p.get_type() == Variant::OBJECT) { RES sr = p; if (sr.is_valid()) { @@ -221,7 +221,7 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Mapset(E->get().name, p); + r->set(E.name, p); } return r; @@ -233,11 +233,11 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map, R local_scene = p_for_scene; - for (List::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if (p.get_type() == Variant::OBJECT) { RES sr = p; if (sr.is_valid()) { @@ -259,21 +259,21 @@ Ref Resource::duplicate(bool p_subresources) const { Ref r = (Resource *)ClassDB::instantiate(get_class()); ERR_FAIL_COND_V(r.is_null(), Ref()); - for (List::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant p = get(E->get().name); + Variant p = get(E.name); if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) { - r->set(E->get().name, p.duplicate(p_subresources)); - } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { + r->set(E.name, p.duplicate(p_subresources)); + } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E.usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { RES sr = p; if (sr.is_valid()) { - r->set(E->get().name, sr->duplicate(p_subresources)); + r->set(E.name, sr->duplicate(p_subresources)); } } else { - r->set(E->get().name, p); + r->set(E.name, p); } } @@ -317,9 +317,9 @@ uint32_t Resource::hash_edited_version() const { List plist; get_property_list(&plist); - for (List::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE && E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - RES res = get(E->get().name); + for (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()) { hash = hash_djb2_one_32(res->hash_edited_version(), hash); } diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index e889586afcd..a8eeaa6602a 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1025,8 +1025,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions_for_type(const String extensions.sort(); - for (List::Element *E = extensions.front(); E; E = E->next()) { - String ext = E->get().to_lower(); + for (String &E : extensions) { + String ext = E.to_lower(); p_extensions->push_back(ext); } } @@ -1036,8 +1036,8 @@ void ResourceFormatLoaderBinary::get_recognized_extensions(List *p_exten ClassDB::get_resource_base_extensions(&extensions); extensions.sort(); - for (List::Element *E = extensions.front(); E; E = E->next()) { - String ext = E->get().to_lower(); + for (String &E : extensions) { + String ext = E.to_lower(); p_extensions->push_back(ext); } } @@ -1528,14 +1528,14 @@ void ResourceFormatSaverBinaryInstance::write_variant(FileAccess *f, const Varia List keys; d.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { /* - if (!_check_type(dict[E->get()])) + if (!_check_type(dict[E])) continue; */ - write_variant(f, E->get(), resource_map, external_resources, string_map); - write_variant(f, d[E->get()], resource_map, external_resources, string_map); + write_variant(f, E, resource_map, external_resources, string_map); + write_variant(f, d[E], resource_map, external_resources, string_map); } } break; @@ -1685,15 +1685,15 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant res->get_property_list(&property_list); - for (List::Element *E = property_list.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - Variant value = res->get(E->get().name); - if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + for (PropertyInfo &E : property_list) { + if (E.usage & PROPERTY_USAGE_STORAGE) { + Variant value = res->get(E.name); + if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { RES sres = value; if (sres.is_valid()) { NonPersistentKey npk; npk.base = res; - npk.property = E->get().name; + npk.property = E.name; non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); @@ -1723,9 +1723,9 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant Dictionary d = p_variant; List keys; d.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - _find_resources(E->get()); - Variant v = d[E->get()]; + for (Variant &E : keys) { + _find_resources(E); + Variant v = d[E]; _find_resources(v); } } break; @@ -1832,39 +1832,39 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p List resources; { - for (List::Element *E = saved_resources.front(); E; E = E->next()) { + for (RES &E : saved_resources) { ResourceData &rd = resources.push_back(ResourceData())->get(); - rd.type = E->get()->get_class(); + rd.type = E->get_class(); List property_list; - E->get()->get_property_list(&property_list); + E->get_property_list(&property_list); - for (List::Element *F = property_list.front(); F; F = F->next()) { - if (skip_editor && F->get().name.begins_with("__editor")) { + for (PropertyInfo &F : property_list) { + if (skip_editor && F.name.begins_with("__editor")) { continue; } - if ((F->get().usage & PROPERTY_USAGE_STORAGE)) { + if ((F.usage & PROPERTY_USAGE_STORAGE)) { Property p; - p.name_idx = get_string_index(F->get().name); + p.name_idx = get_string_index(F.name); - if (F->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + if (F.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { NonPersistentKey npk; - npk.base = E->get(); - npk.property = F->get().name; + npk.base = E; + npk.property = F.name; if (non_persistent_map.has(npk)) { p.value = non_persistent_map[npk]; } } else { - p.value = E->get()->get(F->get().name); + p.value = E->get(F.name); } - Variant default_value = ClassDB::class_get_default_property_value(E->get()->get_class(), F->get().name); + Variant default_value = ClassDB::class_get_default_property_value(E->get_class(), F.name); if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, p.value, default_value))) { continue; } - p.pi = F->get(); + p.pi = F; rd.properties.push_back(p); } @@ -1897,8 +1897,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector ofs_pos; Set used_unique_ids; - for (List::Element *E = saved_resources.front(); E; E = E->next()) { - RES r = E->get(); + for (RES &r : saved_resources) { if (r->get_path() == "" || r->get_path().find("::") != -1) { if (r->get_scene_unique_id() != "") { if (used_unique_ids.has(r->get_scene_unique_id())) { @@ -1912,8 +1911,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Map resource_map; int res_index = 0; - for (List::Element *E = saved_resources.front(); E; E = E->next()) { - RES r = E->get(); + for (RES &r : saved_resources) { if (r->get_path() == "" || r->get_path().find("::") != -1) { if (r->get_scene_unique_id() == "") { String new_id; @@ -1947,17 +1945,15 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p Vector ofs_table; //now actually save the resources - for (List::Element *E = resources.front(); E; E = E->next()) { - ResourceData &rd = E->get(); - + for (ResourceData &rd : resources) { ofs_table.push_back(f->get_position()); save_unicode_string(f, rd.type); f->store_32(rd.properties.size()); - for (List::Element *F = rd.properties.front(); F; F = F->next()) { - Property &p = F->get(); + for (Property &F : rd.properties) { + Property &p = F; f->store_32(p.name_idx); - write_variant(f, p.value, resource_map, external_resources, string_map, F->get().pi); + write_variant(f, p.value, resource_map, external_resources, string_map, F.pi); } } diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index f612b84404d..511c145f2ba 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -146,10 +146,10 @@ 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 (List::Element *F = local_exts.front(); F; F = F->next()) { - if (!found.has(F->get())) { - p_extensions->push_back(F->get()); - found.insert(F->get()); + for (String &F : local_exts) { + if (!found.has(F)) { + p_extensions->push_back(F); + found.insert(F); } } } @@ -175,10 +175,10 @@ void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_ List local_exts; importers[i]->get_recognized_extensions(&local_exts); - for (List::Element *F = local_exts.front(); F; F = F->next()) { - if (!found.has(F->get())) { - p_extensions->push_back(F->get()); - found.insert(F->get()); + for (String &F : local_exts) { + if (!found.has(F)) { + p_extensions->push_back(F); + found.insert(F); } } } @@ -372,8 +372,8 @@ 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 (List::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get()) { + for (String &F : local_exts) { + if (p_extension.to_lower() == F) { r_importers->push_back(importers[i]); } } @@ -393,8 +393,8 @@ 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 (List::Element *F = local_exts.front(); F; F = F->next()) { - if (p_extension.to_lower() == F->get() && importers[i]->get_priority() > priority) { + for (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 c5dfe1f2b05..0c825a62bb3 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -58,8 +58,8 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_ get_recognized_extensions_for_type(p_for_type, &extensions); } - for (List::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { return true; } } @@ -978,15 +978,15 @@ void ResourceLoader::load_translation_remaps() { Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps"); List keys; remaps.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - Array langs = remaps[E->get()]; + for (Variant &E : keys) { + Array langs = remaps[E]; Vector lang_remaps; lang_remaps.resize(langs.size()); for (int i = 0; i < langs.size(); i++) { lang_remaps.write[i] = langs[i]; } - translation_remaps[String(E->get())] = lang_remaps; + translation_remaps[String(E)] = lang_remaps; } } @@ -1071,8 +1071,7 @@ void ResourceLoader::add_custom_loaders() { List global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List::Element *E = global_classes.front(); E; E = E->next()) { - StringName class_name = E->get(); + for (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 80cb85fba3d..e1bd4ed7fea 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -94,8 +94,8 @@ 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 (List::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { recognized = true; } } @@ -236,8 +236,7 @@ void ResourceSaver::add_custom_savers() { List global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List::Element *E = global_classes.front(); E; E = E->next()) { - StringName class_name = E->get(); + for (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/delaunay_3d.h b/core/math/delaunay_3d.h index 6f7209556e3..81adf4d19a8 100644 --- a/core/math/delaunay_3d.h +++ b/core/math/delaunay_3d.h @@ -375,8 +375,7 @@ public: OutputSimplex *ret_simplicesw = ret_simplices.ptrw(); uint32_t simplices_written = 0; - for (List::Element *E = simplex_list.front(); E; E = E->next()) { - Simplex *simplex = E->get(); + for (Simplex *simplex : simplex_list) { bool invalid = false; for (int j = 0; j < 4; j++) { if (simplex->points[j] >= point_count) { diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 0d77bfe9339..9b506269eae 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -192,9 +192,9 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ continue; } - for (List::Element *E = faces.front(); E; E = E->next()) { - if (E->get().plane.distance_to(p_points[i]) > over_tolerance) { - E->get().points_over.push_back(i); + for (Face &E : faces) { + if (E.plane.distance_to(p_points[i]) > over_tolerance) { + E.points_over.push_back(i); break; } } @@ -292,8 +292,8 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ //distribute points into new faces - for (List::Element *>::Element *F = lit_faces.front(); F; F = F->next()) { - Face &lf = F->get()->get(); + for (List::Element *&F : lit_faces) { + Face &lf = F->get(); for (int i = 0; i < lf.points_over.size(); i++) { if (lf.points_over[i] == f.points_over[next]) { //do not add current one @@ -301,8 +301,8 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ } Vector3 p = p_points[lf.points_over[i]]; - for (List::Element *>::Element *E = new_faces.front(); E; E = E->next()) { - Face &f2 = E->get()->get(); + for (List::Element *&E : new_faces) { + Face &f2 = E->get(); if (f2.plane.distance_to(p) > over_tolerance) { f2.points_over.push_back(lf.points_over[i]); break; @@ -320,10 +320,10 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ //put faces that contain no points on the front - for (List::Element *>::Element *E = new_faces.front(); E; E = E->next()) { - Face &f2 = E->get()->get(); + for (List::Element *&E : new_faces) { + Face &f2 = E->get(); if (f2.points_over.size() == 0) { - faces.move_to_front(E->get()); + faces.move_to_front(E); } } @@ -336,19 +336,19 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ Map ret_edges; List ret_faces; - for (List::Element *E = faces.front(); E; E = E->next()) { + for (Face &E : faces) { Geometry3D::MeshData::Face f; - f.plane = E->get().plane; + f.plane = E.plane; for (int i = 0; i < 3; i++) { - f.indices.push_back(E->get().vertices[i]); + f.indices.push_back(E.vertices[i]); } List::Element *F = ret_faces.push_back(f); for (int i = 0; i < 3; i++) { - uint32_t a = E->get().vertices[i]; - uint32_t b = E->get().vertices[(i + 1) % 3]; + uint32_t a = E.vertices[i]; + uint32_t b = E.vertices[(i + 1) % 3]; Edge e(a, b); Map::Element *G = ret_edges.find(e); @@ -439,8 +439,8 @@ Error QuickHull::build(const Vector &p_points, Geometry3D::MeshData &r_ r_mesh.faces.resize(ret_faces.size()); int idx = 0; - for (List::Element *E = ret_faces.front(); E; E = E->next()) { - r_mesh.faces.write[idx++] = E->get(); + for (Geometry3D::MeshData::Face &E : ret_faces) { + r_mesh.faces.write[idx++] = E; } r_mesh.edges.resize(ret_edges.size()); idx = 0; diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index e2db5918e3e..a0ed5db70a2 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -359,9 +359,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { //must be alphabetically sorted for hash to compute names.sort_custom(); - for (List::Element *E = names.front(); E; E = E->next()) { - ClassInfo *t = classes.getptr(E->get()); - ERR_FAIL_COND_V_MSG(!t, 0, "Cannot get class '" + String(E->get()) + "'."); + for (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) { continue; } @@ -388,8 +388,8 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (List::Element *F = snames.front(); F; F = F->next()) { - MethodBind *mb = t->method_map[F->get()]; + for (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); hash = hash_djb2_one_64(mb->get_argument_type(-1), hash); //return @@ -426,9 +426,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (List::Element *F = snames.front(); F; F = F->next()) { - hash = hash_djb2_one_64(F->get().hash(), hash); - hash = hash_djb2_one_64(t->constant_map[F->get()], hash); + for (StringName &F : snames) { + hash = hash_djb2_one_64(F.hash(), hash); + hash = hash_djb2_one_64(t->constant_map[F], hash); } } @@ -444,9 +444,9 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (List::Element *F = snames.front(); F; F = F->next()) { - MethodInfo &mi = t->signal_map[F->get()]; - hash = hash_djb2_one_64(F->get().hash(), hash); + for (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++) { hash = hash_djb2_one_64(mi.arguments[i].type, hash); } @@ -465,23 +465,23 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { snames.sort_custom(); - for (List::Element *F = snames.front(); F; F = F->next()) { - PropertySetGet *psg = t->property_setget.getptr(F->get()); + for (StringName &F : snames) { + PropertySetGet *psg = t->property_setget.getptr(F); ERR_FAIL_COND_V(!psg, 0); - hash = hash_djb2_one_64(F->get().hash(), hash); + hash = hash_djb2_one_64(F.hash(), hash); hash = hash_djb2_one_64(psg->setter.hash(), hash); hash = hash_djb2_one_64(psg->getter.hash(), hash); } } //property list - for (List::Element *F = t->property_list.front(); F; F = F->next()) { - hash = hash_djb2_one_64(F->get().name.hash(), hash); - hash = hash_djb2_one_64(F->get().type, hash); - hash = hash_djb2_one_64(F->get().hint, hash); - hash = hash_djb2_one_64(F->get().hint_string.hash(), hash); - hash = hash_djb2_one_64(F->get().usage, hash); + for (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); + hash = hash_djb2_one_64(F.hint_string.hash(), hash); + hash = hash_djb2_one_64(F.usage, hash); } } @@ -619,16 +619,16 @@ void ClassDB::get_method_list(const StringName &p_class, List *p_met #ifdef DEBUG_METHODS_ENABLED - for (List::Element *E = type->virtual_methods.front(); E; E = E->next()) { - p_methods->push_back(E->get()); + for (MethodInfo &E : type->virtual_methods) { + p_methods->push_back(E); } - for (List::Element *E = type->method_order.front(); E; E = E->next()) { - if (p_exclude_from_properties && type->methods_in_properties.has(E->get())) { + for (StringName &E : type->method_order) { + if (p_exclude_from_properties && type->methods_in_properties.has(E)) { continue; } - MethodBind *method = type->method_map.get(E->get()); + MethodBind *method = type->method_map.get(E); MethodInfo minfo = info_from_bind(method); p_methods->push_back(minfo); @@ -763,8 +763,8 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List while (type) { #ifdef DEBUG_METHODS_ENABLED - for (List::Element *E = type->constant_order.front(); E; E = E->next()) { - p_constants->push_back(E->get()); + for (StringName &E : type->constant_order) { + p_constants->push_back(E); } #else const StringName *K = nullptr; @@ -1073,13 +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 (List::Element *E = check->property_list.front(); E; E = E->next()) { + for (PropertyInfo pi : check->property_list) { if (p_validator) { - PropertyInfo pi = E->get(); p_validator->_validate_property(pi); p_list->push_back(pi); } else { - p_list->push_back(E->get()); + p_list->push_back(pi); } } @@ -1429,8 +1428,8 @@ void ClassDB::get_virtual_methods(const StringName &p_class, List *p ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; while (check) { - for (List::Element *E = check->virtual_methods.front(); E; E = E->next()) { - p_methods->push_back(E->get()); + for (MethodInfo &E : check->virtual_methods) { + p_methods->push_back(E); } if (p_no_inheritance) { @@ -1530,11 +1529,11 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con if (c) { List plist; c->get_property_list(&plist); - for (List::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) { - if (!default_values[p_class].has(E->get().name)) { - Variant v = c->get(E->get().name); - default_values[p_class][E->get().name] = v; + for (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); + default_values[p_class][E.name] = v; } } } diff --git a/core/object/object.cpp b/core/object/object.cpp index 66a4d17b7ba..0e397d85186 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -969,8 +969,8 @@ Vector Object::_get_meta_list_bind() const { List keys; metadata.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - _metaret.push_back(E->get()); + for (Variant &E : keys) { + _metaret.push_back(E); } return _metaret; @@ -979,8 +979,8 @@ Vector Object::_get_meta_list_bind() const { void Object::get_meta_list(List *p_list) const { List keys; metadata.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (Variant &E : keys) { + p_list->push_back(E); } } @@ -1184,8 +1184,8 @@ Array Object::_get_signal_list() const { get_signal_list(&signal_list); Array ret; - for (List::Element *E = signal_list.front(); E; E = E->next()) { - ret.push_back(Dictionary(E->get())); + for (MethodInfo &E : signal_list) { + ret.push_back(Dictionary(E)); } return ret; @@ -1197,8 +1197,7 @@ Array Object::_get_signal_connection_list(const String &p_signal) const { Array ret; - for (List::Element *E = conns.front(); E; E = E->next()) { - Connection &c = E->get(); + for (Connection &c : conns) { if (c.signal.get_name() == p_signal) { ret.push_back(c); } @@ -1297,8 +1296,8 @@ int Object::get_persistent_signal_connection_count() const { } void Object::get_signals_connected_to_this(List *p_connections) const { - for (const List::Element *E = connections.front(); E; E = E->next()) { - p_connections->push_back(E->get()); + for (const Connection &E : connections) { + p_connections->push_back(E); } } @@ -1500,9 +1499,9 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { List keys; d.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - _clear_internal_resource_paths(E->get()); - _clear_internal_resource_paths(d[E->get()]); + for (Variant &E : keys) { + _clear_internal_resource_paths(E); + _clear_internal_resource_paths(d[E]); } } break; default: { @@ -1531,8 +1530,8 @@ void Object::clear_internal_resource_paths() { get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - _clear_internal_resource_paths(get(E->get().name)); + for (PropertyInfo &E : pinfo) { + _clear_internal_resource_paths(get(E.name)); } } @@ -1666,12 +1665,12 @@ void Object::get_translatable_strings(List *p_strings) const { List plist; get_property_list(&plist); - for (List::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED)) { + for (PropertyInfo &E : plist) { + if (!(E.usage & PROPERTY_USAGE_INTERNATIONALIZED)) { continue; } - String text = get(E->get().name); + String text = get(E.name); if (text == "") { continue; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 626a7413e71..5aa032192e7 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -63,8 +63,8 @@ Array Script::_get_script_property_list() { Array ret; List list; get_script_property_list(&list); - for (List::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (PropertyInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -73,8 +73,8 @@ Array Script::_get_script_method_list() { Array ret; List list; get_script_method_list(&list); - for (List::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (MethodInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -83,8 +83,8 @@ Array Script::_get_script_signal_list() { Array ret; List list; get_script_signal_list(&list); - for (List::Element *E = list.front(); E; E = E->next()) { - ret.append(E->get().operator Dictionary()); + for (MethodInfo &E : list) { + ret.append(E.operator Dictionary()); } return ret; } @@ -257,8 +257,8 @@ void ScriptServer::get_global_class_list(List *r_global_classes) { classes.push_back(*K); } classes.sort_custom(); - for (List::Element *E = classes.front(); E; E = E->next()) { - r_global_classes->push_back(E->get()); + for (StringName &E : classes) { + r_global_classes->push_back(E); } } @@ -266,12 +266,12 @@ void ScriptServer::save_global_classes() { List gc; get_global_class_list(&gc); Array gcarr; - for (List::Element *E = gc.front(); E; E = E->next()) { + for (StringName &E : gc) { Dictionary d; - d["class"] = E->get(); - d["language"] = global_classes[E->get()].language; - d["path"] = global_classes[E->get()].path; - d["base"] = global_classes[E->get()].base; + d["class"] = E; + d["language"] = global_classes[E].language; + d["path"] = global_classes[E].path; + d["base"] = global_classes[E].base; gcarr.push_back(d); } @@ -297,10 +297,10 @@ void ScriptServer::save_global_classes() { void ScriptInstance::get_property_state(List> &state) { List pinfo; get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { + for (PropertyInfo &E : pinfo) { + if (E.usage & PROPERTY_USAGE_STORAGE) { Pair p; - p.first = E->get().name; + p.first = E.name; if (get(p.first, p.second)) { state.push_back(p); } @@ -430,16 +430,16 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co void PlaceHolderScriptInstance::get_property_list(List *p_properties) const { if (script->is_placeholder_fallback_enabled()) { - for (const List::Element *E = properties.front(); E; E = E->next()) { - p_properties->push_back(E->get()); + for (const PropertyInfo &E : properties) { + p_properties->push_back(E); } } else { - for (const List::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pinfo = E->get(); + for (const PropertyInfo &E : properties) { + PropertyInfo pinfo = E; if (!values.has(pinfo.name)) { pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE; } - p_properties->push_back(E->get()); + p_properties->push_back(E); } } } @@ -489,11 +489,11 @@ bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const { void PlaceHolderScriptInstance::update(const List &p_properties, const Map &p_values) { Set new_values; - for (const List::Element *E = p_properties.front(); E; E = E->next()) { - StringName n = E->get().name; + for (const PropertyInfo &E : p_properties) { + StringName n = E.name; new_values.insert(n); - if (!values.has(n) || values[n].get_type() != E->get().type) { + if (!values.has(n) || values[n].get_type() != E.type) { if (p_values.has(n)) { values[n] = p_values[n]; } @@ -511,7 +511,7 @@ void PlaceHolderScriptInstance::update(const List &p_properties, c Variant defval; if (script->get_property_default_value(E->key(), defval)) { //remove because it's the same as the default value - if (defval == E->get()) { + if (defval == E) { to_remove.push_back(E->key()); } } @@ -542,8 +542,8 @@ void PlaceHolderScriptInstance::property_set_fallback(const StringName &p_name, } bool found = false; - for (const List::Element *F = properties.front(); F; F = F->next()) { - if (F->get().name == p_name) { + for (const PropertyInfo &F : properties) { + if (F.name == p_name) { found = true; break; } diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cpp index 6808d7602da..adf068eb2f5 100644 --- a/core/object/undo_redo.cpp +++ b/core/object/undo_redo.cpp @@ -39,12 +39,12 @@ void UndoRedo::_discard_redo() { } for (int i = current_action + 1; i < actions.size(); i++) { - for (List::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) { - if (E->get().type == Operation::TYPE_REFERENCE) { - if (E->get().ref.is_valid()) { - E->get().ref.unref(); + for (Operation &E : actions.write[i].do_ops) { + if (E.type == Operation::TYPE_REFERENCE) { + if (E.ref.is_valid()) { + E.ref.unref(); } else { - Object *obj = ObjectDB::get_instance(E->get().object); + Object *obj = ObjectDB::get_instance(E.object); if (obj) { memdelete(obj); } @@ -244,12 +244,12 @@ void UndoRedo::_pop_history_tail() { return; } - for (List::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) { - if (E->get().type == Operation::TYPE_REFERENCE) { - if (E->get().ref.is_valid()) { - E->get().ref.unref(); + for (Operation &E : actions.write[0].undo_ops) { + if (E.type == Operation::TYPE_REFERENCE) { + if (E.ref.is_valid()) { + E.ref.unref(); } else { - Object *obj = ObjectDB::get_instance(E->get().object); + Object *obj = ObjectDB::get_instance(E.object); if (obj) { memdelete(obj); } diff --git a/core/string/optimized_translation.cpp b/core/string/optimized_translation.cpp index 268562d9712..cf0b8d10dbc 100644 --- a/core/string/optimized_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -66,9 +66,9 @@ void OptimizedTranslation::generate(const Ref &p_from) { int total_compression_size = 0; int total_string_size = 0; - for (List::Element *E = keys.front(); E; E = E->next()) { + for (StringName &E : keys) { //hash string - CharString cs = E->get().operator String().utf8(); + CharString cs = E.operator String().utf8(); uint32_t h = hash(0, cs.get_data()); Pair p; p.first = idx; @@ -76,7 +76,7 @@ void OptimizedTranslation::generate(const Ref &p_from) { buckets.write[h % size].push_back(p); //compress string - CharString src_s = p_from->get_message(E->get()).operator String().utf8(); + CharString src_s = p_from->get_message(E).operator String().utf8(); CompressedString ps; ps.orig_len = src_s.size(); ps.offset = total_compression_size; diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 678f8fb207b..981954c8aee 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -841,8 +841,8 @@ Vector Translation::_get_message_list() const { void Translation::_set_messages(const Dictionary &p_messages) { List keys; p_messages.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - translation_map[E->get()] = p_messages[E->get()]; + for (Variant &E : keys) { + translation_map[E] = p_messages[E]; } } diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index f9b4e661e47..afd3b765884 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -47,8 +47,7 @@ void TranslationPO::print_translation_map() { List context_l; translation_map.get_key_list(&context_l); - for (List::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (StringName &ctx : context_l) { file->store_line(" ===== Context: " + String::utf8(String(ctx).utf8()) + " ===== "); const HashMap> &inner_map = translation_map[ctx]; @@ -74,8 +73,7 @@ Dictionary TranslationPO::_get_messages() const { List context_l; translation_map.get_key_list(&context_l); - for (List::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (StringName &ctx : context_l) { const HashMap> &id_str_map = translation_map[ctx]; Dictionary d2; @@ -98,8 +96,7 @@ void TranslationPO::_set_messages(const Dictionary &p_messages) { List context_l; p_messages.get_key_list(&context_l); - for (List::Element *E = context_l.front(); E; E = E->next()) { - StringName ctx = E->get(); + for (Variant &ctx : context_l) { const Dictionary &id_str_map = p_messages[ctx]; HashMap> temp_map; @@ -121,8 +118,8 @@ Vector TranslationPO::_get_message_list() const { get_message_list(&msgs); Vector v; - for (List::Element *E = msgs.front(); E; E = E->next()) { - v.push_back(E->get()); + for (StringName &E : msgs) { + v.push_back(E); } return v; @@ -281,13 +278,13 @@ void TranslationPO::get_message_list(List *r_messages) const { List context_l; translation_map.get_key_list(&context_l); - for (List::Element *E = context_l.front(); E; E = E->next()) { - if (String(E->get()) != "") { + for (StringName &E : context_l) { + if (String(E) != "") { continue; } List msgid_l; - translation_map[E->get()].get_key_list(&msgid_l); + translation_map[E].get_key_list(&msgid_l); for (List::Element *E2 = msgid_l.front(); E2; E2 = E2->next()) { r_messages->push_back(E2->get()); @@ -300,8 +297,8 @@ int TranslationPO::get_message_count() const { translation_map.get_key_list(&context_l); int count = 0; - for (List::Element *E = context_l.front(); E; E = E->next()) { - count += translation_map[E->get()].size(); + for (StringName &E : context_l) { + count += translation_map[E].size(); } return count; } diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 4cd2915ffa7..dbb8dc8283e 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3421,11 +3421,8 @@ String String::format(const Variant &values, String placeholder) const { List keys; d.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); - String val = d[E->get()]; - - new_string = new_string.replace(placeholder.replace("_", key), val); + for (Variant &key : keys) { + new_string = new_string.replace(placeholder.replace("_", key), d[key]); } } else { ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data()); diff --git a/core/variant/callable.cpp b/core/variant/callable.cpp index ca6f3d615e8..2a3a9a4f1a1 100644 --- a/core/variant/callable.cpp +++ b/core/variant/callable.cpp @@ -407,8 +407,8 @@ Array Signal::get_connections() const { object->get_signal_connection_list(name, &connections); Array arr; - for (List::Element *E = connections.front(); E; E = E->next()) { - arr.push_back(E->get()); + for (Object::Connection &E : connections) { + arr.push_back(E); } return arr; } diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index badb5ba1036..12b64650059 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1681,10 +1681,10 @@ String Variant::stringify(List &stack) const { Vector<_VariantStrPair> pairs; - for (List::Element *E = keys.front(); E; E = E->next()) { + for (Variant &E : keys) { _VariantStrPair sp; - sp.key = E->get().stringify(stack); - sp.value = d[E->get()].stringify(stack); + sp.key = E.stringify(stack); + sp.value = d[E].stringify(stack); pairs.push_back(sp); } diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 65ad27d0b4c..c77a5af6d74 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1088,8 +1088,8 @@ 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 (List::Element *E = builtin_method_names[p_type].front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (StringName &E : builtin_method_names[p_type]) { + p_list->push_back(E); } } @@ -1152,12 +1152,12 @@ void Variant::get_method_list(List *p_list) const { obj->get_method_list(p_list); } } else { - for (List::Element *E = builtin_method_names[type].front(); E; E = E->next()) { - const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E->get()); + for (StringName &E : builtin_method_names[type]) { + const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E); ERR_CONTINUE(!method); MethodInfo mi; - mi.name = E->get(); + mi.name = E; //return type if (method->has_return_type) { diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index f9c604fe3e7..dc92ac8ac43 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1586,8 +1586,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str List props; obj->get_property_list(&props); bool first = true; - for (List::Element *E = props.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE || E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { + for (PropertyInfo &E : props) { + if (E.usage & PROPERTY_USAGE_STORAGE || E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) { //must be serialized if (first) { @@ -1596,8 +1596,8 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, ","); } - p_store_string_func(p_store_string_ud, "\"" + E->get().name + "\":"); - write(obj->get(E->get().name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); + p_store_string_func(p_store_string_ud, "\"" + E.name + "\":"); + write(obj->get(E.name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); } } @@ -1615,7 +1615,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "{\n"); for (List::Element *E = keys.front(); E; E = E->next()) { /* - if (!_check_type(dict[E->get()])) + if (!_check_type(dict[E])) continue; */ write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index de1deace632..62228ea87c9 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -1093,9 +1093,9 @@ void Variant::get_property_list(List *p_list) const { const Dictionary *dic = reinterpret_cast(_data._mem); List keys; dic->get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - if (E->get().get_type() == Variant::STRING) { - p_list->push_back(PropertyInfo(Variant::STRING, E->get())); + for (Variant &E : keys) { + if (E.get_type() == Variant::STRING) { + p_list->push_back(PropertyInfo(Variant::STRING, E)); } } } else if (type == OBJECT) { @@ -1106,10 +1106,10 @@ void Variant::get_property_list(List *p_list) const { } else { List members; get_member_list(type, &members); - for (List::Element *E = members.front(); E; E = E->next()) { + for (StringName &E : members) { PropertyInfo pi; - pi.name = E->get(); - pi.type = get_member_type(type, E->get()); + pi.name = E; + pi.type = get_member_type(type, E); p_list->push_back(pi); } } diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index 1f69e81d99f..e9fa952af3e 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -1397,8 +1397,8 @@ uint32_t Variant::get_utility_function_hash(const StringName &p_name) { } void Variant::get_utility_function_list(List *r_functions) { - for (List::Element *E = utility_function_name_table.front(); E; E = E->next()) { - r_functions->push_back(E->get()); + for (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 efeaf32ff76..4c33feb52c7 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -269,11 +269,11 @@ _FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IPAddress p_ip, Str break; // IPv6 uses index. } - for (List::Element *F = c.ip_addresses.front(); F; F = F->next()) { - if (!F->get().is_ipv4()) { + for (IPAddress &F : c.ip_addresses) { + if (!F.is_ipv4()) { continue; // Wrong IP type } - if_ip = F->get(); + if_ip = F; break; } break; diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 5bf3bbf8a47..48e4be498bf 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -8542,8 +8542,8 @@ 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 (List::Element *E = owned.front(); E; E = E->next()) { - free(E->get()); + for (RID E : owned) { + free(E); } } } @@ -8764,13 +8764,13 @@ void RenderingDeviceVulkan::finalize() { List::Element *N = E->next(); if (texture_is_shared(E->get())) { free(E->get()); - owned.erase(E->get()); + owned.erase(E); } E = N; } //free non shared second, this will avoid an error trying to free unexisting textures due to dependencies. - for (List::Element *E = owned.front(); E; E = E->next()) { - free(E->get()); + for (RID E : owned) { + free(E); } } } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 05db9045bdd..0b4f4964c15 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -898,8 +898,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref &p_event) { } // 6-(undo) reinsert overlapped keys - for (List::Element *E = to_restore.front(); E; E = E->next()) { - AnimMoveRestore &amr = E->get(); + for (AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } @@ -1091,9 +1090,9 @@ void AnimationBezierTrackEdit::duplicate_selection() { //reselect duplicated selection.clear(); - for (List>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (Pair &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 174f19280ad..2adfc29f741 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -598,12 +598,12 @@ public: if (ap) { List anims; ap->get_animation_list(&anims); - for (List::Element *E = anims.front(); E; E = E->next()) { + for (StringName &E : anims) { if (animations != String()) { animations += ","; } - animations += String(E->get()); + animations += String(E); } } } @@ -702,8 +702,8 @@ public: for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (List::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; if (from != key_ofs) { key++; continue; @@ -728,8 +728,8 @@ public: bool change_notify_deserved = false; for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -986,8 +986,8 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1137,8 +1137,8 @@ public: same_key_type = false; } - for (List::Element *F = E->value().front(); F; F = F->next()) { - int key = animation->track_find_key(track, F->get(), true); + for (float &F : E->value()) { + int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { first_key = key; @@ -3356,9 +3356,9 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_frame = Engine::get_singleton()->get_frames_drawn(); - for (List::Element *E = insert_data.front(); E; E = E->next()) { + for (InsertData &E : insert_data) { //prevent insertion of multiple tracks - if (E->get().path == p_id.path) { + if (E.path == p_id.path) { return; //already inserted a track for this on this frame } } @@ -3843,9 +3843,9 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b List pinfo; property_info_base.get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == leftover_path[leftover_path.size() - 1]) { - return E->get(); + for (PropertyInfo &E : pinfo) { + if (E.name == leftover_path[leftover_path.size() - 1]) { + return E; } } @@ -4675,21 +4675,21 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { List minfo; base->get_method_list(&minfo); - for (List::Element *E = minfo.front(); E; E = E->next()) { - if (E->get().name == p_method) { + for (MethodInfo &E : minfo) { + if (E.name == p_method) { Dictionary d; d["method"] = p_method; Array params; - int first_defarg = E->get().arguments.size() - E->get().default_arguments.size(); + int first_defarg = E.arguments.size() - E.default_arguments.size(); - for (int i = 0; i < E->get().arguments.size(); i++) { + for (int i = 0; i < E.arguments.size(); i++) { if (i >= first_defarg) { - Variant arg = E->get().default_arguments[i - first_defarg]; + Variant arg = E.default_arguments[i - first_defarg]; params.push_back(arg); } else { Callable::CallError ce; Variant arg; - Variant::construct(E->get().arguments[i].type, arg, nullptr, 0, ce); + Variant::construct(E.arguments[i].type, arg, nullptr, 0, ce); params.push_back(arg); } } @@ -4936,8 +4936,7 @@ void AnimationTrackEditor::_move_selection_commit() { } // 6 - (undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5151,9 +5150,9 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map new_selection; - for (List>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (Pair &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); @@ -5462,8 +5461,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } // 6-(undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5543,8 +5541,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (cleanup_all->is_pressed()) { List names; AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); - for (List::Element *E = names.front(); E; E = E->next()) { - _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get())); + for (StringName &E : names) { + _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E)); } } else { _cleanup_animation(animation); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index b0ec346afe3..012276fe10c 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -854,9 +854,7 @@ void CodeTextEditor::_complete_request() { return; } - for (List::Element *E = entries.front(); E; E = E->next()) { - ScriptCodeCompletionOption &e = E->get(); - + for (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 c439d6a1d4b..f5cfe0fe57b 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -944,9 +944,7 @@ void ConnectionsDock::update_tree() { node_signals2.sort(); } - for (List::Element *E = node_signals2.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); - + for (MethodInfo &mi : node_signals2) { StringName signal_name = mi.name; String signaldesc = "("; PackedStringArray argnames; @@ -1025,8 +1023,8 @@ void ConnectionsDock::update_tree() { List connections; selectedNode->get_signal_connection_list(signal_name, &connections); - for (List::Element *F = connections.front(); F; F = F->next()) { - Connection cn = F->get(); + for (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 bfbd6974091..abe17bf4276 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -447,8 +447,7 @@ Variant CreateDialog::instance_selected() { List pinfo; ((Object *)obj)->get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (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/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index a629bf61596..a1eb71235ca 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -56,8 +56,8 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) void EditorDebuggerRemoteObject::_get_property_list(List *p_list) const { p_list->clear(); //sorry, no want category - for (const List::Element *E = prop_list.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : prop_list) { + p_list->push_back(E); } } diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index a61e9bd73e5..f17ad0d36ce 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -365,13 +365,13 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } TreeItem *category = variables->create_item(parent); - for (List::Element *E = stack.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); + for (TreeItem *E : stack) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); total_cpu += cpu_time; total_gpu += gpu_time; - E->get()->set_metadata(1, cpu_time); - E->get()->set_metadata(2, gpu_time); + E->set_metadata(1, cpu_time); + E->set_metadata(2, gpu_time); } category->set_icon(0, track_icon); @@ -392,11 +392,11 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } } - for (List::Element *E = categories.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); - E->get()->set_text(1, _get_time_as_text(total_cpu)); - E->get()->set_text(2, _get_time_as_text(total_gpu)); + for (TreeItem *E : categories) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); + E->set_text(1, _get_time_as_text(total_cpu)); + E->set_text(2, _get_time_as_text(total_gpu)); } if (ensure_selected) { diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 06b02cceb48..8af59a62de4 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -347,13 +347,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da uint64_t total = 0; - for (List::Element *E = usage.infos.front(); E; E = E->next()) { + for (DebuggerMarshalls::ResourceInfo &E : usage.infos) { TreeItem *it = vmem_tree->create_item(root); - String type = E->get().type; - int bytes = E->get().vram; - it->set_text(0, E->get().path); + String type = E.type; + int bytes = E.vram; + it->set_text(0, E.path); it->set_text(1, type); - it->set_text(2, E->get().format); + it->set_text(2, E.format); it->set_text(3, String::humanize_size(bytes)); total += bytes; diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index c18b8743cdd..0631798b4b2 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -55,8 +55,8 @@ 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 (List::Element *E = ext.front(); E; E = E->next()) { - search->add_filter("*" + E->get()); + for (String &E : ext) { + search->add_filter("*" + E); } search->popup_file_dialog(); } @@ -120,13 +120,13 @@ void DependencyEditor::_fix_all() { Map> candidates; - for (List::Element *E = missing.front(); E; E = E->next()) { - String base = E->get().get_file(); + for (String &E : missing) { + String base = E.get_file(); if (!candidates.has(base)) { candidates[base] = Map(); } - candidates[base][E->get()] = ""; + candidates[base][E] = ""; } _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(), candidates); @@ -166,10 +166,8 @@ void DependencyEditor::_update_list() { bool broken = false; - for (List::Element *E = deps.front(); E; E = E->next()) { + for (String &n : deps) { TreeItem *item = tree->create_item(root); - - String n = E->get(); String path; String type; @@ -741,9 +739,9 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List &path void OrphanResourcesDialog::_delete_confirm() { DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); - EditorFileSystem::get_singleton()->update_file(E->get()); + for (String &E : paths) { + da->remove(E); + EditorFileSystem::get_singleton()->update_file(E); } memdelete(da); refresh(); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index befafec6cb6..9258ff8043f 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -266,20 +266,20 @@ void DocTools::generate(bool p_basic_types) { } List::Element *EO = own_properties.front(); - for (List::Element *E = properties.front(); E; E = E->next()) { + for (PropertyInfo &E : properties) { bool inherited = EO == nullptr; - if (EO && EO->get() == E->get()) { + if (EO && EO->get() == E) { inherited = false; EO = EO->next(); } - if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) { + if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL) { continue; } DocData::PropertyDoc prop; - prop.name = E->get().name; + prop.name = E.name; prop.overridden = inherited; @@ -288,20 +288,20 @@ void DocTools::generate(bool p_basic_types) { if (name == "ProjectSettings") { // Special case for project settings, so that settings are not taken from the current project's settings - if (E->get().name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E->get().name)) { + if (E.name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E.name)) { continue; } - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E->get().name)) { - default_value = ProjectSettings::get_singleton()->property_get_revert(E->get().name); + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E.name)) { + default_value = ProjectSettings::get_singleton()->property_get_revert(E.name); default_value_valid = true; } } } else { - default_value = get_documentation_default_value(name, E->get().name, default_value_valid); + default_value = get_documentation_default_value(name, E.name, default_value_valid); if (inherited) { bool base_default_value_valid = false; - Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid); + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid); if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) { continue; } @@ -309,13 +309,13 @@ void DocTools::generate(bool p_basic_types) { } //used to track uninitialized values using valgrind - //print_line("getting default value for " + String(name) + "." + String(E->get().name)); + //print_line("getting default value for " + String(name) + "." + String(E.name)); if (default_value_valid && default_value.get_type() != Variant::OBJECT) { prop.default_value = default_value.get_construct_string().replace("\n", ""); } - StringName setter = ClassDB::get_property_setter(name, E->get().name); - StringName getter = ClassDB::get_property_getter(name, E->get().name); + StringName setter = ClassDB::get_property_setter(name, E.name); + StringName getter = ClassDB::get_property_getter(name, E.name); prop.setter = setter; prop.getter = getter; @@ -353,10 +353,10 @@ void DocTools::generate(bool p_basic_types) { } if (!found_type) { - if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - prop.type = E->get().hint_string; + if (E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { + prop.type = E.hint_string; } else { - prop.type = Variant::get_type_name(E->get().type); + prop.type = Variant::get_type_name(E.type); } } @@ -367,62 +367,62 @@ void DocTools::generate(bool p_basic_types) { ClassDB::get_method_list(name, &method_list, true); method_list.sort(); - for (List::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) { + for (MethodInfo &E : method_list) { + if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } - if (skip_setter_getter_methods && setters_getters.has(E->get().name)) { + if (skip_setter_getter_methods && setters_getters.has(E.name)) { // Don't skip parametric setters and getters, i.e. method which require // one or more parameters to define what property should be set or retrieved. // E.g. CPUParticles3D::set_param(Parameter param, float value). - if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) { + if (E.arguments.size() == 0 /* getter */ || (E.arguments.size() == 1 && E.return_val.type == Variant::NIL /* setter */)) { continue; } } DocData::MethodDoc method; - method.name = E->get().name; + method.name = E.name; - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (E.flags & METHOD_FLAG_VIRTUAL) { method.qualifiers = "virtual"; } - if (E->get().flags & METHOD_FLAG_CONST) { + if (E.flags & METHOD_FLAG_CONST) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "const"; } - if (E->get().flags & METHOD_FLAG_VARARG) { + if (E.flags & METHOD_FLAG_VARARG) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "vararg"; } - if (E->get().flags & METHOD_FLAG_STATIC) { + if (E.flags & METHOD_FLAG_STATIC) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "static"; } - for (int i = -1; i < E->get().arguments.size(); i++) { + for (int i = -1; i < E.arguments.size(); i++) { if (i == -1) { #ifdef DEBUG_METHODS_ENABLED - DocData::return_doc_from_retinfo(method, E->get().return_val); + DocData::return_doc_from_retinfo(method, E.return_val); #endif } else { - const PropertyInfo &arginfo = E->get().arguments[i]; + const PropertyInfo &arginfo = E.arguments[i]; DocData::ArgumentDoc argument; DocData::argument_doc_from_arginfo(argument, arginfo); - int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size()); + int darg_idx = i - (E.arguments.size() - E.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = E.default_arguments[darg_idx]; argument.default_value = default_arg.get_construct_string(); } @@ -455,12 +455,12 @@ void DocTools::generate(bool p_basic_types) { List constant_list; ClassDB::get_integer_constant_list(name, &constant_list, true); - for (List::Element *E = constant_list.front(); E; E = E->next()) { + for (String &E : constant_list) { DocData::ConstantDoc constant; - constant.name = E->get(); - constant.value = itos(ClassDB::get_integer_constant(name, E->get())); + constant.name = E; + constant.value = itos(ClassDB::get_integer_constant(name, E)); constant.is_value_valid = true; - constant.enumeration = ClassDB::get_integer_constant_enum(name, E->get()); + constant.enumeration = ClassDB::get_integer_constant_enum(name, E); c.constants.push_back(constant); } @@ -469,53 +469,53 @@ void DocTools::generate(bool p_basic_types) { { List l; Theme::get_default()->get_constant_list(cname, &l); - for (List::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; - pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname)); + pd.default_value = itos(Theme::get_default()->get_constant(E, cname)); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_color_list(cname, &l); - for (List::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Color"; - pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string(); + pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string(); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_icon_list(cname, &l); - for (List::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Texture2D"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_list(cname, &l); - for (List::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Font"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_size_list(cname, &l); - for (List::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); - for (List::Element *E = l.front(); E; E = E->next()) { + for (StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "StyleBox"; c.theme_properties.push_back(pd); } @@ -621,8 +621,7 @@ void DocTools::generate(bool p_basic_types) { method_list.push_back(mi); } - for (List::Element *E = method_list.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : method_list) { DocData::MethodDoc method; method.name = mi.name; @@ -675,8 +674,7 @@ void DocTools::generate(bool p_basic_types) { List properties; v.get_property_list(&properties); - for (List::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : properties) { DocData::PropertyDoc property; property.name = pi.name; property.type = Variant::get_type_name(pi.type); @@ -688,10 +686,10 @@ void DocTools::generate(bool p_basic_types) { List constants; Variant::get_constants_for_type(Variant::Type(i), &constants); - for (List::Element *E = constants.front(); E; E = E->next()) { + for (StringName &E : constants) { DocData::ConstantDoc constant; - constant.name = E->get(); - Variant value = Variant::get_constant_value(Variant::Type(i), E->get()); + constant.name = E; + Variant value = Variant::get_constant_value(Variant::Type(i), E); constant.value = value.get_type() == Variant::INT ? itos(value) : value.get_construct_string(); constant.is_value_valid = true; c.constants.push_back(constant); @@ -723,9 +721,8 @@ void DocTools::generate(bool p_basic_types) { Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (List::Element *E = singletons.front(); E; E = E->next()) { + for (Engine::Singleton &s : singletons) { DocData::PropertyDoc pd; - Engine::Singleton &s = E->get(); if (!s.ptr) { continue; } @@ -743,13 +740,13 @@ void DocTools::generate(bool p_basic_types) { List utility_functions; Variant::get_utility_function_list(&utility_functions); utility_functions.sort_custom(); - for (List::Element *E = utility_functions.front(); E; E = E->next()) { + for (StringName &E : utility_functions) { DocData::MethodDoc md; - md.name = E->get(); + md.name = E; //return - if (Variant::has_utility_function_return_value(E->get())) { + if (Variant::has_utility_function_return_value(E)) { PropertyInfo pi; - pi.type = Variant::get_utility_function_return_type(E->get()); + pi.type = Variant::get_utility_function_return_type(E); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -758,13 +755,13 @@ void DocTools::generate(bool p_basic_types) { md.return_type = ad.type; } - if (Variant::is_utility_function_vararg(E->get())) { + if (Variant::is_utility_function_vararg(E)) { md.qualifiers = "vararg"; } else { - for (int i = 0; i < Variant::get_utility_function_argument_count(E->get()); i++) { + for (int i = 0; i < Variant::get_utility_function_argument_count(E); i++) { PropertyInfo pi; - pi.type = Variant::get_utility_function_argument_type(E->get(), i); - pi.name = Variant::get_utility_function_argument_name(E->get(), i); + pi.type = Variant::get_utility_function_argument_type(E, i); + pi.name = Variant::get_utility_function_argument_name(E, i); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -793,8 +790,7 @@ void DocTools::generate(bool p_basic_types) { List minfo; lang->get_public_functions(&minfo); - for (List::Element *E = minfo.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (MethodInfo &mi : minfo) { DocData::MethodDoc md; md.name = mi.name; @@ -813,7 +809,7 @@ void DocTools::generate(bool p_basic_types) { int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = mi.default_arguments[darg_idx]; ad.default_value = default_arg.get_construct_string(); } @@ -827,10 +823,10 @@ void DocTools::generate(bool p_basic_types) { List> cinfo; lang->get_public_constants(&cinfo); - for (List>::Element *E = cinfo.front(); E; E = E->next()) { + for (Pair &E : cinfo) { DocData::ConstantDoc cd; - cd.name = E->get().first; - cd.value = E->get().second; + cd.name = E.first; + cd.value = E.second; cd.is_value_valid = true; c.constants.push_back(cd); } diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index d94ac218373..5a85c8b31b6 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -920,15 +920,15 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { List effects; ClassDB::get_inheriters_from_class("AudioEffect", &effects); effects.sort_custom(); - for (List::Element *E = effects.front(); E; E = E->next()) { - if (!ClassDB::can_instantiate(E->get())) { + for (StringName &E : effects) { + if (!ClassDB::can_instantiate(E)) { continue; } - Ref icon = EditorNode::get_singleton()->get_class_icon(E->get()); - String name = E->get().operator String().replace("AudioEffect", ""); + Ref icon = EditorNode::get_singleton()->get_class_icon(E); + String name = E.operator String().replace("AudioEffect", ""); effect_options->add_item(name); - effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get()); + effect_options->set_item_metadata(effect_options->get_item_count() - 1, E); effect_options->set_item_icon(effect_options->get_item_count() - 1, icon); } @@ -1331,8 +1331,8 @@ EditorAudioBuses::EditorAudioBuses() { file_dialog = memnew(EditorFileDialog); List ext; ResourceLoader::get_recognized_extensions_for_type("AudioBusLayout", &ext); - for (List::Element *E = ext.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get() + "; Audio Bus Layout"); + for (String &E : ext) { + file_dialog->add_filter("*." + E + "; Audio Bus Layout"); } add_child(file_dialog); file_dialog->connect("file_selected", callable_mp(this, &EditorAudioBuses::_file_dialog_callback)); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index c6d52107cd2..e81f788290f 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -46,12 +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 (List::Element *E = afn.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get()); + for (String &E : afn) { + file_dialog->add_filter("*." + E); } - for (List::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (AutoLoadInfo &info : autoload_cache) { if (info.node && info.in_editor) { get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } @@ -102,8 +101,8 @@ 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 (List::Element *E = keywords.front(); E; E = E->next()) { - if (E->get() == p_name) { + for (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."); } @@ -379,8 +378,7 @@ void EditorAutoloadSettings::update_autoload() { Map to_remove; List to_add; - for (List::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (AutoLoadInfo &info : autoload_cache) { to_remove.insert(info.name, info); } @@ -392,9 +390,7 @@ void EditorAutoloadSettings::update_autoload() { List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -483,9 +479,7 @@ void EditorAutoloadSettings::update_autoload() { // Load new/changed autoloads List nodes_to_add; - for (List::Element *E = to_add.front(); E; E = E->next()) { - AutoLoadInfo *info = E->get(); - + for (AutoLoadInfo *info : to_add) { info->node = _create_autoload(info->path); ERR_CONTINUE(!info->node); @@ -518,8 +512,8 @@ void EditorAutoloadSettings::update_autoload() { } } - for (List::Element *E = nodes_to_add.front(); E; E = E->next()) { - get_tree()->get_root()->add_child(E->get()); + for (Node *E : nodes_to_add) { + get_tree()->get_root()->add_child(E); } updating_autoload = false; @@ -649,8 +643,8 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int i = 0; - for (List::Element *F = autoload_cache.front(); F; F = F->next()) { - orders.write[i++] = F->get().order; + for (AutoLoadInfo &F : autoload_cache) { + orders.write[i++] = F.order; } orders.sort(); @@ -661,9 +655,9 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & i = 0; - for (List::Element *F = autoload_cache.front(); F; F = F->next()) { - undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, orders[i++]); - undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, F->get().order); + for (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); } orders.clear(); @@ -764,9 +758,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { // Make first cache List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -799,9 +791,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_cache.push_back(info); } - for (List::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); - + for (AutoLoadInfo &info : autoload_cache) { info.node = _create_autoload(info.path); if (info.node) { @@ -904,8 +894,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } EditorAutoloadSettings::~EditorAutoloadSettings() { - for (List::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (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 3529a4fbdc1..9204974d1aa 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -299,13 +299,13 @@ void EditorData::copy_object_params(Object *p_object) { List pinfo; p_object->get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") { + for (PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) || E.name == "script" || E.name == "scripts") { continue; } PropertyData pd; - pd.name = E->get().name; + pd.name = E.name; pd.value = p_object->get(pd.name); clipboard.push_back(pd); } @@ -404,9 +404,9 @@ 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 (List::Element *E = clipboard.front(); E; E = E->next()) { - String name = E->get().name; - undo_redo.add_do_property(p_object, name, E->get().value); + for (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)); } undo_redo.commit_action(); @@ -616,8 +616,8 @@ bool EditorData::check_and_update_scene(int p_idx) { //transfer selection List new_selection; - for (List::Element *E = edited_scene.write[p_idx].selection.front(); E; E = E->next()) { - NodePath p = edited_scene[p_idx].root->get_path_to(E->get()); + for (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) { new_selection.push_back(new_node); @@ -841,8 +841,8 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, p_history->history = es.history_stored; p_selection->clear(); - for (List::Element *E = es.selection.front(); E; E = E->next()) { - p_selection->add_node(E->get()); + for (Node *E : es.selection) { + p_selection->add_node(E); } set_editor_states(es.editor_states); @@ -964,9 +964,9 @@ void EditorData::script_class_save_icon_paths() { _script_class_icon_paths.get_key_list(&keys); Dictionary d; - for (List::Element *E = keys.front(); E; E = E->next()) { - if (ScriptServer::is_global_class(E->get())) { - d[E->get()] = _script_class_icon_paths[E->get()]; + for (StringName &E : keys) { + if (ScriptServer::is_global_class(E)) { + d[E] = _script_class_icon_paths[E]; } } @@ -996,8 +996,8 @@ void EditorData::script_class_load_icon_paths() { List keys; d.get_key_list(&keys); - for (List::Element *E = keys.front(); E; E = E->next()) { - String name = E->get().operator String(); + for (Variant &E : keys) { + String name = E.operator String(); _script_class_icon_paths[name] = d[name]; String path = ScriptServer::get_global_class_path(name); @@ -1038,8 +1038,8 @@ void EditorSelection::add_node(Node *p_node) { changed = true; nl_changed = true; Object *meta = nullptr; - for (List::Element *E = editor_plugins.front(); E; E = E->next()) { - meta = E->get()->call("_get_editor_data", p_node); + for (Object *E : editor_plugins) { + meta = E->call("_get_editor_data", p_node); if (meta) { break; } @@ -1076,8 +1076,8 @@ bool EditorSelection::is_selected(Node *p_node) const { Array EditorSelection::_get_transformable_selected_nodes() { Array ret; - for (List::Element *E = selected_node_list.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (Node *E : selected_node_list) { + ret.push_back(E); } return ret; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index fc483b46b72..2c36c1dea13 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -80,9 +80,9 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { } void EditorExportPreset::_get_property_list(List *p_list) const { - for (const List::Element *E = properties.front(); E; E = E->next()) { - if (platform->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (platform->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -436,9 +436,9 @@ Ref EditorExportPlatform::create_preset() { List options; get_export_options(&options); - for (List::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); - preset->values[E->get().option.name] = E->get().default_value; + for (ExportOption &E : options) { + preset->properties.push_back(E.option); + preset->values[E.option.name] = E.default_value; } return preset; @@ -679,9 +679,9 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai platform->get_preset_features(p_preset, &feature_list); FeatureContainers result; - for (List::Element *E = feature_list.front(); E; E = E->next()) { - result.features.insert(E->get()); - result.features_pv.push_back(E->get()); + for (String &E : feature_list) { + result.features.insert(E); + result.features_pv.push_back(E); } if (p_preset->get_custom_features() != String()) { @@ -752,9 +752,7 @@ Error EditorExportPlatform::export_project_files(const Ref & List props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -899,8 +897,8 @@ Error EditorExportPlatform::export_project_files(const Ref & Set remap_features; - for (List::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (String &F : remaps) { + String remap = F; String feature = remap.get_slice(".", 1); if (features.has(feature)) { remap_features.insert(feature); @@ -913,8 +911,8 @@ Error EditorExportPlatform::export_project_files(const Ref & err = OK; - for (List::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (String &F : remaps) { + String remap = F; if (remap == "path") { String remapped_path = config->get_value("remap", remap); Vector array = FileAccess::get_file_as_array(remapped_path); @@ -1362,7 +1360,7 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (breakpoints.size()) { r_flags.push_back("--breakpoints"); String bpoints; - for (const List::Element *E = breakpoints.front(); E; E = E->next()) { + for (List::Element *E = breakpoints.front(); E; E = E->next()) { bpoints += E->get().replace(" ", "%20"); if (E->next()) { bpoints += ","; @@ -1436,8 +1434,8 @@ void EditorExport::_save() { String option_section = "preset." + itos(i) + ".options"; - for (const List::Element *E = preset->get_properties().front(); E; E = E->next()) { - config->set_value(option_section, E->get().name, preset->get(E->get().name)); + for (const PropertyInfo &E : preset->get_properties()) { + config->set_value(option_section, E.name, preset->get(E.name)); } } @@ -1642,10 +1640,10 @@ void EditorExport::load_config() { config->get_section_keys(option_section, &options); - for (List::Element *E = options.front(); E; E = E->next()) { - Variant value = config->get_value(option_section, E->get()); + for (String &E : options) { + Variant value = config->get_value(option_section, E); - preset->set(E->get(), value); + preset->set(E, value); } add_export_preset(preset); @@ -1684,11 +1682,11 @@ void EditorExport::update_export_presets() { preset->properties.clear(); preset->values.clear(); - for (List::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); + for (EditorExportPlatform::ExportOption &E : options) { + preset->properties.push_back(E.option); - StringName option_name = E->get().option.name; - preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().default_value; + StringName option_name = E.option.name; + preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value; } } } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index e36cc7bc2e0..1bc852000d4 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -527,9 +527,8 @@ 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 (List::Element *E = child_classes.front(); E; E = E->next()) { - String name = E->get(); - if (name.begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { + for (StringName &name : child_classes) { + if (String(name).begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { continue; } _fill_classes_from(class_item, name, p_selected); @@ -597,9 +596,9 @@ void EditorFeatureProfileManager::_class_list_item_selected() { TreeItem *properties = property_list->create_item(root); properties->set_text(0, TTR("Class Properties:")); - for (List::Element *E = props.front(); E; E = E->next()) { - String name = E->get().name; - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (PropertyInfo &E : props) { + String name = E.name; + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } TreeItem *property = property_list->create_item(properties); @@ -609,7 +608,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); property->set_text(0, name.capitalize()); property->set_metadata(0, name); - String icon_type = Variant::get_type_name(E->get().type); + String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); } } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index ed2edb5a5d1..f11e8d350d2 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -830,8 +830,8 @@ void EditorFileDialog::update_file_list() { while (!files.is_empty()) { bool match = patterns.is_empty(); - for (List::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { + for (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 82a71c0e0c7..72c0c0794e7 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -457,8 +457,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo memdelete(md5s); //imported files are gone, reimport - for (List::Element *E = to_check.front(); E; E = E->next()) { - if (!FileAccess::exists(E->get())) { + for (String &E : to_check) { + if (!FileAccess::exists(E)) { return true; } } @@ -497,9 +497,7 @@ bool EditorFileSystem::_update_scan_actions() { Vector reimports; Vector reloads; - for (List::Element *E = scan_actions.front(); E; E = E->next()) { - ItemAction &ia = E->get(); - + for (ItemAction &ia : scan_actions) { switch (ia.action) { case ItemAction::ACTION_NONE: { } break; @@ -1027,8 +1025,8 @@ 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 (List::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); + for (String &E : paths) { + da->remove(E); } da->remove(p_file + ".import"); memdelete(da); @@ -1368,8 +1366,8 @@ Vector EditorFileSystem::_get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); Vector ret; - for (List::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (String &E : deps) { + ret.push_back(E); } return ret; @@ -1549,15 +1547,14 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List options; importer->get_import_options(&options); //set default values - for (List::Element *E = options.front(); E; E = E->next()) { - source_file_options[p_files[i]][E->get().option.name] = E->get().default_value; + for (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 (List::Element *E = sk.front(); E; E = E->next()) { - String param = E->get(); + for (String ¶m : sk) { Variant value = config->get_value("params", param); //override with whathever is in file source_file_options[p_files[i]][param] = value; @@ -1631,9 +1628,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List options; importer->get_import_options(&options); //set default values - for (List::Element *F = options.front(); F; F = F->next()) { - String base = F->get().option.name; - Variant v = F->get().default_value; + for (ResourceImporter::ImportOption &F : options) { + String base = F.option.name; + Variant v = F.default_value; if (source_file_options[file].has(base)) { v = source_file_options[file][base]; } @@ -1712,8 +1709,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Maphas_section("params")) { List sk; cf->get_section_keys("params", &sk); - for (List::Element *E = sk.front(); E; E = E->next()) { - params[E->get()] = cf->get_value("params", E->get()); + for (String &E : sk) { + params[E] = cf->get_value("params", E); } } if (p_custom_importer == String() && cf->has_section("remap")) { @@ -1754,9 +1751,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map opts; importer->get_import_options(&opts); - for (List::Element *E = opts.front(); E; E = E->next()) { - if (!params.has(E->get().option.name)) { //this one is not present - params[E->get().option.name] = E->get().default_value; + for (ResourceImporter::ImportOption &E : opts) { + if (!params.has(E.option.name)) { //this one is not present + params[E.option.name] = E.default_value; } } @@ -1766,8 +1763,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map v; d.get_key_list(&v); - for (List::Element *E = v.front(); E; E = E->next()) { - params[E->get()] = d[E->get()]; + for (Variant &E : v) { + params[E] = d[E]; } } @@ -1807,10 +1804,10 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map::Element *E = import_variants.front(); E; E = E->next()) { - String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); + for (String &E : import_variants) { + String path = base_path.c_escape() + "." + E + "." + importer->get_save_extension(); - f->store_line("path." + E->get() + "=\"" + path + "\""); + f->store_line("path." + E + "=\"" + path + "\""); dest_paths.push_back(path); } } else { @@ -1833,9 +1830,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map::Element *E = gen_files.front(); E; E = E->next()) { - genf.push_back(E->get()); - dest_paths.push_back(E->get()); + for (String &E : gen_files) { + genf.push_back(E); + dest_paths.push_back(E); } String value; @@ -1859,8 +1856,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map::Element *E = opts.front(); E; E = E->next()) { - String base = E->get().option.name; + for (ResourceImporter::ImportOption &E : opts) { + String base = E.option.name; String value; VariantWriter::write_to_string(params[base], value); f->store_line(base + "=" + value); @@ -2080,9 +2077,8 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S List sk; config->get_section_keys("params", &sk); - for (List::Element *E = sk.front(); E; E = E->next()) { + for (String ¶m : sk) { //not very clean, but should work - String param = E->get(); String value = config->get_value("params", param); if (value == p_group_file) { config->set_value("params", param, p_new_location); @@ -2131,14 +2127,14 @@ void EditorFileSystem::_update_extensions() { List extensionsl; ResourceLoader::get_recognized_extensions_for_type("", &extensionsl); - for (List::Element *E = extensionsl.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (String &E : extensionsl) { + valid_extensions.insert(E); } extensionsl.clear(); ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl); - for (List::Element *E = extensionsl.front(); E; E = E->next()) { - import_extensions.insert(E->get()); + for (String &E : extensionsl) { + import_extensions.insert(E); } } diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 5d6c415d394..7b7cf0bf48d 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -109,10 +109,10 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p List plist; p_node->get_property_list(&plist); - for (List::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (E->get().type == Variant::OBJECT) { - RES res = p_node->get(E->get().name); + for (PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (E.type == Variant::OBJECT) { + RES res = p_node->get(E.name); if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { Vector res_unfolds = _get_unfolds(res.ptr()); resource_folds.push_back(res->get_path()); @@ -228,41 +228,41 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set &resources) { Set unfold_group; - for (List::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_CATEGORY) { + for (PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_CATEGORY) { group = ""; group_base = ""; } - if (E->get().usage & PROPERTY_USAGE_GROUP) { - group = E->get().name; - group_base = E->get().hint_string; + if (E.usage & PROPERTY_USAGE_GROUP) { + group = E.name; + group_base = E.hint_string; if (group_base.ends_with("_")) { group_base = group_base.substr(0, group_base.length() - 1); } } //can unfold - if (E->get().usage & PROPERTY_USAGE_EDITOR) { + if (E.usage & PROPERTY_USAGE_EDITOR) { if (group != "") { //group - if (group_base == String() || E->get().name.begins_with(group_base)) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + if (group_base == String() || E.name.begins_with(group_base)) { + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { unfold_group.insert(group); } } } else { //path - int last = E->get().name.rfind("/"); + int last = E.name.rfind("/"); if (last != -1) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { - unfold_group.insert(E->get().name.substr(0, last)); + unfold_group.insert(E.name.substr(0, last)); } } } - if (E->get().type == Variant::OBJECT) { - RES res = p_object->get(E->get().name); - print_line("res: " + String(E->get().name) + " valid " + itos(res.is_valid())); + if (E.type == Variant::OBJECT) { + RES res = p_object->get(E.name); + print_line("res: " + String(E.name) + " valid " + itos(res.is_valid())); if (res.is_valid()) { print_line("path " + res->get_path()); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 9fa2007597b..9a0dd4e3bc4 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1508,9 +1508,9 @@ String EditorInspector::get_selected_path() const { } void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref ped) { - for (List::Element *F = ped->added_editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to(F->get().property_editor); - current_vbox->add_child(F->get().property_editor); + for (EditorInspectorPlugin::AddedEditor &F : ped->added_editors) { + EditorProperty *ep = Object::cast_to(F.property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->object = object; @@ -1524,19 +1524,19 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Refconnect("resource_selected", callable_mp(this, &EditorInspector::_resource_selected), varray(), CONNECT_DEFERRED); ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED); - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = 0; } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List(); @@ -1648,8 +1648,7 @@ void EditorInspector::update_tree() { Color sscolor = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); - for (List>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref ped = E->get(); + for (Ref ped : valid_plugins) { ped->parse_begin(object); _parse_added_editors(main_vbox, ped); } @@ -1746,8 +1745,7 @@ void EditorInspector::update_tree() { category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); } - for (List>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref ped = E->get(); + for (Ref ped : valid_plugins) { ped->parse_category(object, p.name); _parse_added_editors(main_vbox, ped); } @@ -1948,36 +1946,35 @@ void EditorInspector::update_tree() { doc_hint = descr; } - for (List>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref ped = E->get(); + for (Ref ped : valid_plugins) { bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage, wide_editors); List editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector ped->added_editors.clear(); - for (List::Element *F = editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to(F->get().property_editor); + for (EditorInspectorPlugin::AddedEditor &F : editors) { + EditorProperty *ep = Object::cast_to(F.property_editor); if (ep) { //set all this before the control gets the ENTER_TREE notification ep->object = object; - if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { + if (F.properties.size()) { + if (F.properties.size() == 1) { //since it's one, associate: - ep->property = F->get().properties[0]; + ep->property = F.properties[0]; ep->property_usage = p.usage; //and set label? } - if (F->get().label != String()) { - ep->set_label(F->get().label); + if (F.label != String()) { + ep->set_label(F.label); } else { //use existin one ep->set_label(name); } - for (int i = 0; i < F->get().properties.size(); i++) { - String prop = F->get().properties[i]; + for (int i = 0; i < F.properties.size(); i++) { + String prop = F.properties[i]; if (!editor_property_map.has(prop)) { editor_property_map[prop] = List(); @@ -1995,7 +1992,7 @@ void EditorInspector::update_tree() { ep->set_deletable(deletable_properties); } - current_vbox->add_child(F->get().property_editor); + current_vbox->add_child(F.property_editor); if (ep) { ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed)); @@ -2031,8 +2028,7 @@ void EditorInspector::update_tree() { } } - for (List>::Element *E = valid_plugins.front(); E; E = E->next()) { - Ref ped = E->get(); + for (Ref ped : valid_plugins) { ped->parse_end(); _parse_added_editors(main_vbox, ped); } @@ -2045,10 +2041,10 @@ void EditorInspector::update_property(const String &p_prop) { return; } - for (List::Element *E = editor_property_map[p_prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } @@ -2157,24 +2153,24 @@ bool EditorInspector::is_using_folding() { } void EditorInspector::collapse_all_folding() { - for (List::Element *E = sections.front(); E; E = E->next()) { - E->get()->fold(); + for (EditorInspectorSection *E : sections) { + E->fold(); } for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List::Element *E = F->get().front(); E; E = E->next()) { - E->get()->collapse_all_folding(); + for (EditorProperty *E : F->get()) { + E->collapse_all_folding(); } } } void EditorInspector::expand_all_folding() { - for (List::Element *E = sections.front(); E; E = E->next()) { - E->get()->unfold(); + for (EditorInspectorSection *E : sections) { + E->unfold(); } for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List::Element *E = F->get().front(); E; E = E->next()) { - E->get()->expand_all_folding(); + for (EditorProperty *E : F->get()) { + E->expand_all_folding(); } } } @@ -2239,9 +2235,9 @@ void EditorInspector::_edit_request_change(Object *p_object, const String &p_pro void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { if (autoclear && editor_property_map.has(p_name)) { - for (List::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - if (E->get()->is_checkable()) { - E->get()->set_checked(true); + for (EditorProperty *E : editor_property_map[p_name]) { + if (E->is_checkable()) { + E->set_checked(true); } } } @@ -2308,8 +2304,8 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } if (editor_property_map.has(p_name)) { - for (List::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { - E->get()->update_reload_status(); + for (EditorProperty *E : editor_property_map[p_name]) { + E->update_reload_status(); } } } @@ -2395,10 +2391,10 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { Variant to_create; List pinfo; object->get_property_list(&pinfo); - for (List::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == p_path) { + for (PropertyInfo &E : pinfo) { + if (E.name == p_path) { Callable::CallError ce; - Variant::construct(E->get().type, to_create, nullptr, 0, ce); + Variant::construct(E.type, to_create, nullptr, 0, ce); break; } } @@ -2406,10 +2402,10 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { } if (editor_property_map.has(p_path)) { - for (List::Element *E = editor_property_map[p_path].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[p_path]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } @@ -2426,9 +2422,9 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) if (F->key() == property_selected) { continue; } - for (List::Element *E = F->get().front(); E; E = E->next()) { - if (E->get()->is_selected()) { - E->get()->deselect(); + for (EditorProperty *E : F->get()) { + if (E->is_selected()) { + E->deselect(); } } } @@ -2485,11 +2481,11 @@ void EditorInspector::_notification(int p_what) { refresh_countdown -= get_process_delta_time(); if (refresh_countdown <= 0) { for (Map>::Element *F = editor_property_map.front(); F; F = F->next()) { - for (List::Element *E = F->get().front(); E; E = E->next()) { - if (!E->get()->is_cache_valid()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : F->get()) { + if (!E->is_cache_valid()) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } } @@ -2508,10 +2504,10 @@ void EditorInspector::_notification(int p_what) { while (pending.size()) { StringName prop = pending.front()->get(); if (editor_property_map.has(prop)) { - for (List::Element *E = editor_property_map[prop].front(); E; E = E->next()) { - E->get()->update_property(); - E->get()->update_reload_status(); - E->get()->update_cache(); + for (EditorProperty *E : editor_property_map[prop]) { + E->update_property(); + E->update_reload_status(); + E->update_cache(); } } pending.erase(pending.front()); @@ -2599,8 +2595,7 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li } Set added; - for (List>::Element *E = classes.front(); E; E = E->next()) { - Ref