Commit Graph

1797 Commits

Author SHA1 Message Date
16d551a8dd Improve error messages in ResourceLoader
- Remove part of the "Failed loading resource" message about opening
  the project in the editor, as it's sometimes misleading.
- Fix `(expected type: )` appearing at the end of the
  "No loader found for resource:" error message.
2025-06-13 02:00:59 +02:00
94d7a54fea Merge pull request #107402 from mihe/lsp-uid-bug
Stop `FileAccess::fix_path` from emitting errors for invalid UIDs
2025-06-12 23:32:51 +02:00
1a64b6b5b6 Merge pull request #106913 from Ivorforce/string-resize-uninitialized
Rename `String::resize` to `resize_uninitialized`
2025-06-12 22:48:45 +02:00
d160d71796 Stop FileAccess::fix_path from emitting errors for invalid UIDs 2025-06-12 17:21:44 +02:00
e9f5bd8e51 Merge pull request #107355 from beicause/fix-resource-script-property-save
Fix `script` property of custom resources inherited from scripts are not saved
2025-06-12 11:56:46 +02:00
b13a0e1834 Rename String::resize to resize_uninitialized, to better communicate to callers that new characters must be initialized. 2025-06-11 18:13:02 +02:00
1498eb327f Make IPAddress to String conversion explicit. 2025-06-11 15:44:16 +02:00
784823ada1 Fix script property of custom resources inherited from scripts are not saved 2025-06-10 23:03:13 +08:00
24494d840e Core: Unify display of error type prefixes 2025-06-09 20:18:51 +03:00
f948ab5366 Implement uid Resource references in VariantWriter
VariantWriter now writes the uid and the path into Resource() references.
This change will affect ConfigFile, used for .import or project settings.
2025-06-08 06:11:35 -07:00
19a94159a2 Fix async resource loading progress on empty p_original_path 2025-06-04 15:24:39 +02:00
344b8ce1f1 Merge pull request #106190 from aaronfranke/compression64
Support 64-bit sizes in Compression
2025-06-03 15:30:24 -05:00
454e4f817c Make build profile project detection also set build options 2025-06-03 11:11:33 -03:00
5777a88b76 Support 64-bit sizes in Compression 2025-06-03 00:03:01 -07:00
7a3d2f6779 Merge pull request #106606 from aaronfranke/pow2_64
Add 64-bit versions of core power of 2 functions
2025-06-02 18:51:56 -05:00
e8a02152c4 Merge pull request #105757 from bruvzg/no_temp
[PCK] Move directory to the end of file, write exported/saved PCK in place.
2025-06-02 18:51:28 -05:00
8cb2817976 [PCK] Move directory to the end of file, write exported/saved PCK in place. 2025-06-02 12:54:09 +03:00
f6f1df7d73 Add 64-bit versions of core power of 2 functions 2025-06-01 23:11:12 -07:00
873833b4a7 Remove redundant queue_redraw() & fix typo 2025-05-29 17:22:32 +02:00
0f67c3e992 Merge pull request #104522 from Ivorforce/localvector-force-trivial-resize
Core: Add `resize_initialized` and `resize_uninitialized` to `Vector` and `LocalVector`
2025-05-27 09:39:27 -05:00
63dff62948 Merge pull request #100673 from RandomShaper/res_duplicate
Overhaul resource duplication
2025-05-27 09:39:25 -05:00
4cb8a0c77e Add resize_initialized and resize_uninitialized to Vector. These functions serve as replacements for resize, to make sure the caller understands whether elements need to be initialized 'by hand' after the call. 2025-05-26 18:35:41 +02:00
c38b856f39 Merge pull request #106717 from KoBeWi/uid_in_path_factory
Expose helper methods for converting UIDs
2025-05-26 11:24:40 -05:00
342266cfd9 Overhaul Variant::duplicate() for resources
This in the scope of a duplication triggered via any type in the `Variant` realm. that is, the following: `Variant` itself, `Array` and `Dictionary`. That includes invoking `duplicate()` from scripts.

A `duplicate_deep(deep_subresources_mode)` method is added to `Variant`, `Array` and `Dictionary` (for compatibility reasons, simply adding an extra parameter was not possible). The default value for it is `RESOURCE_DEEP_DUPLICATE_NONE`, which is like calling `duplicate(true)`.

Remarks:
- The results of copying resources via those `Variant` types are exactly the same as if the copy were initiated from the `Resource` type at C++.
- In order to keep some separation between `Variant` and the higher-level animal which is `Resource`, `Variant` still contains the original code for that, so it's self-sufficient unless there's a `Resource` involved. Once the deep copy finds a `Resource` that has to be copied according to the duplication parameters, the algorithm invokes the `Resource` duplication machinery. When the stack is unwind back to a nesting level `Variant` can handle, `Variant` duplication logic keeps functioning.

While that is good from a responsibility separation standpoint, that would have a caveat: `Variant` would not be aware of the mapping between original and duplicate subresources and so wouldn't be able to keep preventing multiple duplicates.

To avoid that, this commit also introduces a wormwhole, a sharing mechanism by which `Variant` and `Resource` can collaborate in managing the lifetime of the original-to-duplicates map. The user-visible benefit is that the overduplicate prevention works as broadly as the whole `Variant` entity being copied, including all nesting levels, regardless how disconnected the data members containing resources may be across al the nesting levels. In other words, despite the aforementioned division of duties between `Variant` and `Resource` duplication logic, the duplicates map is shared among them. It's created when first finding a `Resource` and, however how deep the copy was working at that point, the map kept alive unitl the stack is unwind to the root user call, until the first step of the recursion.

Thanks to that common map of duplicates, this commit is able to fix the issue that `Resource::duplicate_for_local_scene()` used to ignore overridden duplicate logic.
2025-05-26 10:06:40 +02:00
2a03b459b9 Overhaul Resource::duplicate()
Thanks to a refactor, `Resource::duplicate_for_local_scene()` and `Resource::duplicate()` are now both users of the same, parametrized, implementation.

`Resource::duplicate()` now honors deepness in a more consistent and predictable fashion. `Resource::duplicate_deep()` is added (instead of just adding a parameter to the former, for compatibility needs).

The behavior after this change is as follows:
  - Deep (`deep=true`, formerly `subresources=true`):
    - Previously, only resources found as direct property values of the one to copy would be, recursively, duplicated.
    - Now, in addition, arrays and dictionaries are walked so the copy is truly deep, and only local subresources found across are copied.
    - Previously, subresources would be duplicated as many times as being referenced throughout the main resource.
    - Now, each subresource is only duplicated once and from that point, a referenced to that single copy is used. That's the enhanced behavior that `duplicate_for_local_scene()` already featured.
    - The behavior with respect to packed arrays is still duplication.
    - Formerly, arrays and dictionaries were recursive duplicated, with resources ignored.
    - Now, arrays and dictionaries are recursive duplicated, with resources duplicated.
    - When doing it through `duplicate_deep()`, there's a` deep_subresources_mode` parameter, with various possibilites to control if no resources are duplicated (so arrays, etc. are, but keeping referencing the originals), if only the internal ones are (resources with no non-local path, the default), or if all of them are. The default is to copy every subresource, just like `duplicate(true)`.
  - Not deep (`deep=false`, formerly `subresources=false`): <a name="resource-shallow"></a>
    - Previously, the first level of resources found as direct property values would be duplicated unconditionally. Packed arrays, arrays and dictionaries were non-recursively duplicated.
    - Now, no subresource found at any level in any form will be duplicated, but the original reference kept instead. Packed arrays, arrays and dictionaries are referenced, not duplicated at all.
    - Now, resources found as values of always-duplicate properties are duplicated, recursively or not matching what was requested for the root call.

This commit also changes what's the virtual method to override to customize the duplication (now it's the protected `_duplicate()` instead of the public `duplicate()`).
2025-05-26 10:05:25 +02:00
9c37ca5383 Expose helper methods for converting UIDs 2025-05-25 00:26:16 +02:00
d609cf62a0 Implement get_filesystem_type on macOS and Linux. 2025-05-23 23:05:06 +03:00
a2aefab4c7 Merge pull request #106486 from BlueCube3310/image-ch-detect-fix
Image: Fix detecting color channels
2025-05-19 08:01:40 -05:00
f5383df83b Overhaul Resource::duplicate_for_local_scene()
- Serves as a first step for future refactors.
- Code is simpler.
- Algorithm is more efficient: instead of two passes (dumb copy + resolve copies), it's single-pass.
- Now obeys `PROPERTY_USAGE_NEVER_DUPLICATE`.
- Now handles deep self-references (the resource to be duplicated being referenced somewhere deep).
2025-05-19 10:01:11 +02:00
0f9986470a Image: Fix detecting color channels 2025-05-16 12:47:57 +02:00
3207066e19 Add Memory::alloc_static_zeroed to allocate memory that's filled with zeroes.
This is generally faster than `malloc` followed by `memset` / loop-set to 0.
2025-05-13 01:57:05 +02:00
8fb3697916 Avoid single character String allocations when appending characters
Removed calls to String::chr() when appending characters to Strings in Expression, Resource, and VariantParser, to avoid creating temporary Strings for each character.  Also updated the Resource case to resize String up front, since size is known.
2025-05-12 17:35:42 -04:00
ba710dfde3 Merge pull request #106170 from IphStich/fix-typed-dictionary
Fix for debugging typed dictionaries
2025-05-09 11:29:18 -05:00
057759d413 Fix for debugging typed dictionaries 2025-05-08 21:11:23 +10:00
2c789788c0 mbedTLS: Fix concurrency issues with TLS
When we first integrated mbedTLS, we decided not to enable
MBEDTLS_THREADING_C (which adds mutex locking to calls modifying the
state), and instead to simply create separate contexts ("states") for
each connection.

This worked fine until recently.
Sadly, mbedTLS 3 added a global state for the new PSA crypto
functionalities (which are required to support TLSv1.3).
This results in TLSv1.3 connections to access and modify the global
state concurrently when running in threads.

This commit enables MBEDTLS_THREADING_C, and MBEDTLS_THREADING_C_ALT to
provide a generic Godot implementation using the engine Mutex class.
2025-05-08 11:45:00 +02:00
0ce3d75c20 Merge pull request #93783 from aaronp64/json_stringify_performance
Improve `JSON::stringify` performance
2025-05-07 12:48:28 -05:00
f13b4b760a Improve JSON::stringify performance
- Changed stringify to call static function _stringify directly, instead of creating JSON object
- Changed colon and end_statement from String to const char * to avoid extra allocations in each _stringify call
- Pass result String reference to each _stringify call to append to instead of allocating new String in each call

These changes make JSON::stringify around 2-3x faster in most cases
2025-05-06 18:27:32 -04:00
579feb387c Core: Add [[nodiscard]] to string-like classes 2025-05-06 12:23:41 -05:00
4cb030d6bf Merge pull request #106089 from mihe/rogue-newlines
Fix empty lines being added for errors with no script backtrace
2025-05-06 08:38:04 -05:00
7efe897343 Merge pull request #106085 from clayjohn/texture-decompress-import
Fix loading BPTC/ASTC textures on devices that don't support them
2025-05-06 08:38:04 -05:00
5bc01f2994 Merge pull request #105080 from beicause/basisu-ktx2-settings
BasisU: Use KTX2 format and add import options to configure encoder
2025-05-05 11:24:20 -05:00
31b90246e7 Fix empty lines being added for errors with no script backtrace 2025-05-05 13:27:21 +02:00
2b3923880a Continue checking for a texture decompression path even if end of import file is not reached 2025-05-05 00:19:32 -07:00
237597b01f BasisU: Use KTX2 format and add import options to configure encoder 2025-05-03 01:45:38 +08:00
01fc9aee6c Core: Modernize C headers with C++ equivalents 2025-05-02 08:23:01 -05:00
5af4bef46f Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
f8a8d6cf04 Merge pull request #105700 from dementive/config-file-get-improvement
Improve ConfigFile get_sections and get_section_keys by returning Vector<String>
2025-04-27 19:21:31 -05:00
3947cbe3b2 Merge pull request #104386 from Repiteo/core/cpp-math
Core: Replace C math headers with C++ equivalents
2025-04-27 19:21:22 -05:00
b8e44a0000 Improve ConfigFile get_sections and get_section_keys by returning Vector<String> 2025-04-24 20:10:31 -04:00
28089c40c1 Merge pull request #91006 from reduz/live-backtrace
Ability to print and log script backtraces
2025-04-24 17:18:52 -05:00