| 2025 | } |
| 2026 | |
| 2027 | void ResourceFormatSaverCompatTextInstance::_find_resources(const Variant &p_variant, bool p_main) { |
| 2028 | switch (p_variant.get_type()) { |
| 2029 | case Variant::OBJECT: { |
| 2030 | Ref<Resource> res = p_variant; |
| 2031 | |
| 2032 | if (!CompatFormatLoader::resource_is_resource(res, ver_major) || res.is_null() || external_resources.has(res) || res->get_meta(SNAME("_skip_save_"), false)) { |
| 2033 | return; |
| 2034 | } |
| 2035 | |
| 2036 | if (!p_main && (!bundle_resources) && !res->is_built_in()) { |
| 2037 | if (res->get_path() == local_path) { |
| 2038 | ERR_PRINT("Circular reference to resource being saved found: '" + local_path + "' will be null next time it's loaded."); |
| 2039 | return; |
| 2040 | } |
| 2041 | |
| 2042 | // Use a numeric ID as a base, because they are sorted in natural order before saving. |
| 2043 | // This increases the chances of thread loading to fetch them first. |
| 2044 | #if 0 |
| 2045 | String id = itos(external_resources.size() + 1) + "_" + Resource::generate_scene_unique_id(); |
| 2046 | #endif |
| 2047 | String id = get_id_for_ext_resource(res, external_resources.size()); |
| 2048 | external_resources[res] = id; |
| 2049 | return; |
| 2050 | } |
| 2051 | |
| 2052 | if (resource_set.has(res)) { |
| 2053 | return; |
| 2054 | } |
| 2055 | |
| 2056 | resource_set.insert(res); |
| 2057 | |
| 2058 | List<PropertyInfo> property_list; |
| 2059 | |
| 2060 | res->get_property_list(&property_list); |
| 2061 | property_list.sort(); |
| 2062 | |
| 2063 | List<PropertyInfo>::Element *I = property_list.front(); |
| 2064 | |
| 2065 | while (I) { |
| 2066 | PropertyInfo pi = I->get(); |
| 2067 | |
| 2068 | if (pi.usage & PROPERTY_USAGE_STORAGE) { |
| 2069 | Variant v = res->get(I->get().name); |
| 2070 | |
| 2071 | if (pi.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { |
| 2072 | NonPersistentKey npk; |
| 2073 | npk.base = res; |
| 2074 | npk.property = pi.name; |
| 2075 | non_persistent_map[npk] = v; |
| 2076 | |
| 2077 | Ref<Resource> sres = v; |
| 2078 | if (sres.is_valid()) { |
| 2079 | resource_set.insert(sres); |
| 2080 | saved_resources.push_back(sres); |
| 2081 | } else { |
| 2082 | _find_resources(v); |
| 2083 | } |
| 2084 | } else { |
nothing calls this directly
no test coverage detected