From d3f8563298f201f36c91b89195b6175b3aa70b0d Mon Sep 17 00:00:00 2001 From: Yuri Rubinsky Date: Mon, 24 Oct 2022 11:28:10 +0300 Subject: [PATCH 01/13] Fix crash when calling `fill` method on an empty `Image` (cherry picked from commit adec51cde87d29dd74efb6e5cd0167990de8d569) --- core/image.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/image.cpp b/core/image.cpp index e79389f2ce4..42d2df78ad2 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -2477,6 +2477,9 @@ void Image::_repeat_pixel_over_subsequent_memory(uint8_t *p_pixel, int p_pixel_s } void Image::fill(const Color &p_color) { + if (data.size() == 0) { + return; + } ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats."); lock(); @@ -2495,6 +2498,9 @@ void Image::fill(const Color &p_color) { } void Image::fill_rect(const Rect2 &p_rect, const Color &p_color) { + if (data.size() == 0) { + return; + } ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill rect in compressed or custom image formats."); Rect2i r = Rect2i(0, 0, width, height).clip(p_rect.abs()); From b694fa39275b6e7acdfe29624e44531b7e921549 Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Tue, 4 Apr 2023 20:56:53 +0700 Subject: [PATCH 02/13] ci: wait for static check results before starting builds (cherry picked from commit 93b7bcb33da2c2395e51b097922240e76e9def71) --- .github/workflows/android_builds.yml | 3 +- .github/workflows/ios_builds.yml | 3 +- .github/workflows/javascript_builds.yml | 3 +- .github/workflows/linux_builds.yml | 3 +- .github/workflows/macos_builds.yml | 3 +- .github/workflows/runner.yml | 46 +++++++++++++++++++++++++ .github/workflows/server_builds.yml | 3 +- .github/workflows/static_checks.yml | 3 +- .github/workflows/windows_builds.yml | 3 +- 9 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/runner.yml diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 04db037a864..6f684627050 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -1,5 +1,6 @@ name: 🤖 Android Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index bc98f7b1ac2..880e725013d 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -1,5 +1,6 @@ name: 🍏 iOS Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: diff --git a/.github/workflows/javascript_builds.yml b/.github/workflows/javascript_builds.yml index cdb8255a143..39c03f9caeb 100644 --- a/.github/workflows/javascript_builds.yml +++ b/.github/workflows/javascript_builds.yml @@ -1,5 +1,6 @@ name: 🌐 JavaScript Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index 97e6dc0a3ad..4fca00e84f7 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -1,5 +1,6 @@ name: 🐧 Linux Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index a65aafa0d9d..6f2380fd6d3 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -1,5 +1,6 @@ name: 🍎 macOS Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml new file mode 100644 index 00000000000..1981da5b8f0 --- /dev/null +++ b/.github/workflows/runner.yml @@ -0,0 +1,46 @@ +name: 🔗 GHA +on: [push, pull_request] + +concurrency: + group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner + cancel-in-progress: true + +jobs: + static-checks: + name: 📊 Static + uses: ./.github/workflows/static_checks.yml + + android-build: + name: 🤖 Android + needs: static-checks + uses: ./.github/workflows/android_builds.yml + + ios-build: + name: 🍏 iOS + needs: static-checks + uses: ./.github/workflows/ios_builds.yml + + javascript-build: + name: 🌐 JavaScript + needs: static-checks + uses: ./.github/workflows/javascript_builds.yml + + linux-build: + name: 🐧 Linux + needs: static-checks + uses: ./.github/workflows/linux_builds.yml + + macos-build: + name: 🍎 macOS + needs: static-checks + uses: ./.github/workflows/macos_builds.yml + + server-build: + name: ☁ Server + needs: static-checks + uses: ./.github/workflows/server_builds.yml + + windows-build: + name: 🏁 Windows + needs: static-checks + uses: ./.github/workflows/windows_builds.yml diff --git a/.github/workflows/server_builds.yml b/.github/workflows/server_builds.yml index 5e42dc43432..6c3d13575e5 100644 --- a/.github/workflows/server_builds.yml +++ b/.github/workflows/server_builds.yml @@ -1,5 +1,6 @@ name: ☁ Server Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings env: diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index 79c082666a6..e22c0dfc372 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -1,5 +1,6 @@ name: 📊 Static Checks -on: [push, pull_request] +on: + workflow_call: concurrency: group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 6d5c97a6ebf..dc86be252a7 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -1,5 +1,6 @@ name: 🏁 Windows Builds -on: [push, pull_request] +on: + workflow_call: # Global Settings # SCONS_CACHE for windows must be set in the build environment From 5f9be6fc07d494a235ba378b622622b875523fda Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Fri, 21 Oct 2022 14:06:42 -0500 Subject: [PATCH 03/13] Fix .gitignore ignores part of the committed repo. (cherry picked from commit 37d68929e8ab3a1cab550a4cb83152eb13012f8c) --- .gitignore | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 518c3419125..2fa5fa6fc60 100644 --- a/.gitignore +++ b/.gitignore @@ -246,9 +246,6 @@ xcuserdata/ x64/ x86/ -# Do not ignore x86 folders anywhere under thirdparty libraries -!thirdparty/**/x86/ - [Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ @@ -258,6 +255,12 @@ bld/ [Ll]og/ [Ll]ogs/ +# Do not ignore arch-specific folders anywhere under thirdparty libraries +!thirdparty/**/x64/ +!thirdparty/**/x86/ +!thirdparty/**/arm/ +!thirdparty/**/arm64/ + # Visual Studio 2015/2017 cache/options directory .vs/ From 5267fcb1bc775d0d33ab2755832828022eac73ad Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Sat, 1 Jul 2023 08:40:58 -0500 Subject: [PATCH 04/13] Fix: incorrectly .gitignored files. (cherry picked from commit 90f3992036b2f2fc1b4d08d1cc854d9cd62f6930) --- platform/android/java/editor/src/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 platform/android/java/editor/src/.gitignore diff --git a/platform/android/java/editor/src/.gitignore b/platform/android/java/editor/src/.gitignore new file mode 100644 index 00000000000..c081ec3425d --- /dev/null +++ b/platform/android/java/editor/src/.gitignore @@ -0,0 +1 @@ +!/debug From 2ce2f632f0e054ad988db89c5ea280425fd765d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 29 Aug 2023 13:17:26 +0200 Subject: [PATCH 05/13] Remove too greedy GCOV ignores from `.gitignore` This would cause `updown.png` to be ignored in our default theme in 3.x. These ignores were added in #36800 for #36572 (see that PR for usage instructions). From a quick test, using `--output-file` for `lcov` and `--output-directory` for genhtml let us output the files in a way that won't conflict with the Git repository (e.g. in `bin/`, or outside the Git repo). (cherry picked from commit 5c38e4216174f21362058a1a77938f5a63e2ffef) --- .gitignore | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 2fa5fa6fc60..619e6e04660 100644 --- a/.gitignore +++ b/.gitignore @@ -131,23 +131,9 @@ cppcheck-cppcheck-build-dir/ *.pydevproject *.launch -# Gcov and Lcov code coverage -*.gcno +# GCOV code coverage *.gcda -*.gcov.html -*.func.html -*.func-sort-c.html -*index-sort-f.html -*index-sort-l.html -*index.html -godot.info -amber.png -emerald.png -glass.png -ruby.png -snow.png -updown.png -gcov.css +*.gcno # Geany *.geany From 5013dde8fcb7d6a898acce5f5bf5e7fb4fe52486 Mon Sep 17 00:00:00 2001 From: "ocean (they/them)" Date: Tue, 29 Aug 2023 17:56:25 -0400 Subject: [PATCH 06/13] Build system: add option for MSVC incremental linking. (cherry picked from commit bbafe14970cf2a101b8b04dbfafeeaa9ddfb5d4d) --- methods.py | 3 +++ platform/windows/detect.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/methods.py b/methods.py index d6dacef4cef..a5a4a2fdda5 100644 --- a/methods.py +++ b/methods.py @@ -787,6 +787,9 @@ def generate_vs_project(env, num_jobs): if env["custom_modules"]: common_build_postfix.append("custom_modules=%s" % env["custom_modules"]) + if env["incremental_link"]: + common_build_postfix.append("incremental_link=yes") + result = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)]) return result diff --git a/platform/windows/detect.py b/platform/windows/detect.py index a54f730679b..df3a5ffd50f 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -73,6 +73,7 @@ def get_opts(): BoolVariable("use_thinlto", "Use ThinLTO", False), BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True), BoolVariable("use_asan", "Use address sanitizer (ASAN)", False), + BoolVariable("incremental_link", "Use MSVC incremental linking. May increase or decrease build times.", False), ] @@ -216,8 +217,9 @@ def configure_msvc(env, manual_msvc_config): else: env.AppendUnique(CCFLAGS=["/MD"]) - # MSVC incremental linking is broken and _increases_ link time (GH-77968). - env.Append(LINKFLAGS=["/INCREMENTAL:NO"]) + # MSVC incremental linking is broken and may _increase_ link time (GH-77968). + if not env["incremental_link"]: + env.Append(LINKFLAGS=["/INCREMENTAL:NO"]) env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"]) env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding. From f3cb2e199139d0c3be47dcbfa7d6767f479358b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 4 Sep 2023 16:05:38 +0200 Subject: [PATCH 07/13] CI: Bump version for `actions/checkout@v4` (cherry picked from commit de14f1d29530410b12a10a01a3d704ca658b152b) --- .github/workflows/android_builds.yml | 2 +- .github/workflows/ios_builds.yml | 2 +- .github/workflows/javascript_builds.yml | 2 +- .github/workflows/linux_builds.yml | 2 +- .github/workflows/macos_builds.yml | 2 +- .github/workflows/server_builds.yml | 2 +- .github/workflows/static_checks.yml | 2 +- .github/workflows/windows_builds.yml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 6f684627050..a9b623edf0d 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -18,7 +18,7 @@ jobs: name: Template (target=release, tools=no) steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Azure repositories are not reliable, we need to prevent azure giving us packages. - name: Make apt sources.list use the default Ubuntu repositories diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index 880e725013d..8c65167961c 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -18,7 +18,7 @@ jobs: name: Template (target=release, tools=no) steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Godot build cache uses: ./.github/actions/godot-cache diff --git a/.github/workflows/javascript_builds.yml b/.github/workflows/javascript_builds.yml index 39c03f9caeb..60ca56777be 100644 --- a/.github/workflows/javascript_builds.yml +++ b/.github/workflows/javascript_builds.yml @@ -20,7 +20,7 @@ jobs: name: Template (target=release, tools=no) steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Emscripten latest uses: mymindstorm/setup-emsdk@v12 diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index 4fca00e84f7..6bcb2ee7a6f 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -49,7 +49,7 @@ jobs: artifact: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Linux dependencies shell: bash diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index 6f2380fd6d3..1790284c305 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -32,7 +32,7 @@ jobs: tools: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Godot build cache uses: ./.github/actions/godot-cache diff --git a/.github/workflows/server_builds.yml b/.github/workflows/server_builds.yml index 6c3d13575e5..9f34041ce23 100644 --- a/.github/workflows/server_builds.yml +++ b/.github/workflows/server_builds.yml @@ -31,7 +31,7 @@ jobs: tools: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Linux dependencies shell: bash diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index e22c0dfc372..082ebdebfa5 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Azure repositories are not reliable, we need to prevent Azure giving us packages. - name: Make apt sources.list use the default Ubuntu repositories diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index dc86be252a7..99b02a05261 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -35,7 +35,7 @@ jobs: tools: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Godot build cache uses: ./.github/actions/godot-cache From 930390a2fbc31c14b0ce8ff83776303e97277c02 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 29 Aug 2023 09:15:34 +0800 Subject: [PATCH 08/13] Fix TouchScreenButton not redrawn when texture changes Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> (cherry picked from commit aea0c1235db50a89b0a8f5680a787d4143ee8e25) --- scene/2d/touch_screen_button.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 504966354dc..0fd33ee9de0 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -33,9 +33,19 @@ #include "core/input_map.h" #include "core/os/input.h" #include "core/os/os.h" +#include "scene/scene_string_names.h" void TouchScreenButton::set_texture(const Ref &p_texture) { + if (texture == p_texture) { + return; + } + if (texture.is_valid()) { + texture->disconnect(SceneStringNames::get_singleton()->changed, this, "update"); + } texture = p_texture; + if (texture.is_valid()) { + texture->connect(SceneStringNames::get_singleton()->changed, this, "update", varray(), CONNECT_REFERENCE_COUNTED); + } update(); } @@ -44,7 +54,16 @@ Ref TouchScreenButton::get_texture() const { } void TouchScreenButton::set_texture_pressed(const Ref &p_texture_pressed) { + if (texture_pressed == p_texture_pressed) { + return; + } + if (texture_pressed.is_valid()) { + texture_pressed->disconnect(SceneStringNames::get_singleton()->changed, this, "update"); + } texture_pressed = p_texture_pressed; + if (texture_pressed.is_valid()) { + texture_pressed->connect(SceneStringNames::get_singleton()->changed, this, "update", varray(), CONNECT_REFERENCE_COUNTED); + } update(); } @@ -61,16 +80,16 @@ Ref TouchScreenButton::get_bitmask() const { } void TouchScreenButton::set_shape(const Ref &p_shape) { - if (shape.is_valid()) { - shape->disconnect("changed", this, "update"); + if (shape == p_shape) { + return; + } + if (shape.is_valid()) { + shape->disconnect(SceneStringNames::get_singleton()->changed, this, "update"); } - shape = p_shape; - if (shape.is_valid()) { - shape->connect("changed", this, "update"); + shape->connect(SceneStringNames::get_singleton()->changed, this, "update"); } - update(); } From 442677a3f0544e66ee0616737a5695ad77bbe6b6 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Tue, 29 Aug 2023 13:46:53 +0300 Subject: [PATCH 09/13] [3.x] Core: Add recursion level check for `VariantWriter::write()` (cherry picked from commit 0213cbbf205bf323583122d2601bd7c70d11fdb2) --- core/variant_parser.cpp | 32 +++++++++++++++++++++++++++----- core/variant_parser.h | 2 +- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index bb4f7c47cb1..5f617b6866a 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1532,7 +1532,7 @@ static String rtos_fix(double p_value) { } } -Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud) { +Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud, int p_recursion_count) { switch (p_variant.get_type()) { case Variant::NIL: { p_store_string_func(p_store_string_ud, "null"); @@ -1649,6 +1649,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } break; case Variant::OBJECT: { + if (unlikely(p_recursion_count > MAX_RECURSION)) { + ERR_PRINT("Max recursion reached"); + p_store_string_func(p_store_string_ud, "null"); + return OK; + } + p_recursion_count++; + Object *obj = p_variant; if (!obj) { @@ -1698,7 +1705,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } 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); + write(obj->get(E->get().name), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count); } } @@ -1707,6 +1714,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } break; case Variant::DICTIONARY: { + if (unlikely(p_recursion_count > MAX_RECURSION)) { + ERR_PRINT("Max recursion reached"); + p_store_string_func(p_store_string_ud, "{}"); + return OK; + } + p_recursion_count++; + Dictionary dict = p_variant; List keys; @@ -1719,9 +1733,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str if (!_check_type(dict[E->get()])) continue; */ - write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); + write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count); p_store_string_func(p_store_string_ud, ": "); - write(dict[E->get()], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); + write(dict[E->get()], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count); if (E->next()) { p_store_string_func(p_store_string_ud, ",\n"); } else { @@ -1733,6 +1747,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } break; case Variant::ARRAY: { + if (unlikely(p_recursion_count > MAX_RECURSION)) { + ERR_PRINT("Max recursion reached"); + p_store_string_func(p_store_string_ud, "[]"); + return OK; + } + p_recursion_count++; + p_store_string_func(p_store_string_ud, "[ "); Array array = p_variant; int len = array.size(); @@ -1740,7 +1761,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str if (i > 0) { p_store_string_func(p_store_string_ud, ", "); } - write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); + write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, p_recursion_count); } p_store_string_func(p_store_string_ud, " ]"); @@ -1871,6 +1892,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, " )"); } break; + default: { } } diff --git a/core/variant_parser.h b/core/variant_parser.h index f3e4357de99..6c1a7518c70 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -141,7 +141,7 @@ public: typedef Error (*StoreStringFunc)(void *ud, const String &p_string); typedef String (*EncodeResourceFunc)(void *ud, const RES &p_resource); - static Error write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud); + static Error write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud, int p_recursion_count = 0); static Error write_to_string(const Variant &p_variant, String &r_string, EncodeResourceFunc p_encode_res_func = nullptr, void *p_encode_res_ud = nullptr); }; From dc095b8ad4609011ea65383fefd5f339a069fdd4 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sun, 27 Aug 2023 16:22:01 +0200 Subject: [PATCH 10/13] Add check to ensure registered classes are declared Checks that all classes registered to `ClassDB` have been properly declared with `GDCLASS` (cherry picked from commit 4b205afd3dd890cf26d03ebe9f2d58c91161ef73) --- core/class_db.h | 3 +++ core/object.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/core/class_db.h b/core/class_db.h index 0fcef8b8d41..82bcb8da25d 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -170,6 +170,7 @@ public: template static void register_class() { GLOBAL_LOCK_FUNCTION; + static_assert(TypesAreSame::value, "Class not declared properly, please use GDCLASS."); T::initialize_class(); ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); @@ -182,6 +183,7 @@ public: template static void register_virtual_class() { GLOBAL_LOCK_FUNCTION; + static_assert(TypesAreSame::value, "Class not declared properly, please use GDCLASS."); T::initialize_class(); ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); @@ -198,6 +200,7 @@ public: template static void register_custom_instance_class() { GLOBAL_LOCK_FUNCTION; + static_assert(TypesAreSame::value, "Class not declared properly, please use GDCLASS."); T::initialize_class(); ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); diff --git a/core/object.h b/core/object.h index a31f826ec05..58b1c08e76c 100644 --- a/core/object.h +++ b/core/object.h @@ -267,6 +267,7 @@ private: friend class ClassDB; \ \ public: \ + typedef m_class self_type; \ virtual String get_class() const { \ return String(#m_class); \ } \ @@ -405,6 +406,8 @@ class ObjectRC; class Object { public: + typedef Object self_type; + enum ConnectFlags { CONNECT_DEFERRED = 1, From d20dfcfe79a177c4cd34ce8720302b48ab544e5d Mon Sep 17 00:00:00 2001 From: SysError99 Date: Tue, 29 Aug 2023 03:12:53 +0700 Subject: [PATCH 11/13] [3.x] Fix JavaScript callback memory leak (cherry picked from commit 8ac91f813f364ed3e8b4b6be1b0770124af0d1b0) --- .../javascript/js/libs/library_godot_javascript_singleton.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/javascript/js/libs/library_godot_javascript_singleton.js b/platform/javascript/js/libs/library_godot_javascript_singleton.js index ec58ce48e6e..e6ebef0262f 100644 --- a/platform/javascript/js/libs/library_godot_javascript_singleton.js +++ b/platform/javascript/js/libs/library_godot_javascript_singleton.js @@ -205,7 +205,9 @@ const GodotJSWrapper = { return; } const args = Array.from(arguments); - func(p_ref, GodotJSWrapper.get_proxied(args), args.length); + const argsProxy = new GodotJSWrapper.MyProxy(args); + func(p_ref, argsProxy.get_id(), args.length); + argsProxy.unref(); }; id = GodotJSWrapper.get_proxied(cb); return id; From 86b409f067b3199a6cfcdbc4da5779a26cae335f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 5 Sep 2023 14:56:53 +0200 Subject: [PATCH 12/13] Web: Workaround Emscripten 3.1.42+ LTO regression Fixes #80010. (cherry picked from commit b064008c07be856d6f3a5079d11746137e03ede5) --- platform/javascript/detect.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index a88094f9192..8a61813b5a3 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -108,6 +108,12 @@ def configure(env): env.Append(CCFLAGS=["-flto=full"]) env.Append(LINKFLAGS=["-flto=full"]) + if env["use_thinlto"] or env["use_lto"]: + # Workaround https://github.com/emscripten-core/emscripten/issues/19781. + cc_semver = tuple(get_compiler_version(env)) + if cc_semver >= (3, 1, 42): + env.Append(LINKFLAGS=["-Wl,-u,scalbnf"]) + # Sanitizers if env["use_ubsan"]: env.Append(CCFLAGS=["-fsanitize=undefined"]) From 2eaa385a6446e93dcbbefb26b4679c21f09d4c62 Mon Sep 17 00:00:00 2001 From: "Wilson E. Alvarez" Date: Thu, 16 Mar 2023 10:30:43 -0400 Subject: [PATCH 13/13] Fix AudioEffectRecord circular reference (cherry picked from commit ae1b209d6e5d86e4924338f8bffebe2f45d21698) --- servers/audio/effects/audio_effect_record.cpp | 37 ++++++++++--------- servers/audio/effects/audio_effect_record.h | 6 +-- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp index 1f274c0570c..912693c434b 100644 --- a/servers/audio/effects/audio_effect_record.cpp +++ b/servers/audio/effects/audio_effect_record.cpp @@ -67,11 +67,6 @@ bool AudioEffectRecordInstance::process_silence() const { void AudioEffectRecordInstance::_io_thread_process() { while (is_recording) { - //Check: The current recording has been requested to stop - if (!base->recording_active) { - is_recording = false; - } - _update_buffer(); if (is_recording) { @@ -119,6 +114,7 @@ void AudioEffectRecordInstance::init() { } void AudioEffectRecordInstance::finish() { + is_recording = false; #ifdef NO_THREADS AudioServer::get_singleton()->remove_update_callback(&AudioEffectRecordInstance::_update, this); #else @@ -126,14 +122,9 @@ void AudioEffectRecordInstance::finish() { #endif } -AudioEffectRecordInstance::~AudioEffectRecordInstance() { - finish(); -} - Ref AudioEffectRecord::instance() { Ref ins; ins.instance(); - ins->base = Ref(this); ins->is_recording = false; //Re-using the buffer size calculations from audio_effect_delay.cpp @@ -159,16 +150,19 @@ Ref AudioEffectRecord::instance() { ins->ring_buffer_read_pos = 0; ensure_thread_stopped(); - current_instance = ins; - if (recording_active) { + bool is_currently_recording = false; + if (current_instance != nullptr) { + is_currently_recording = current_instance->is_recording; + } + if (is_currently_recording) { ins->init(); } + current_instance = ins; return ins; } void AudioEffectRecord::ensure_thread_stopped() { - recording_active = false; if (current_instance != nullptr) { current_instance->finish(); } @@ -178,20 +172,24 @@ void AudioEffectRecord::set_recording_active(bool p_record) { if (p_record) { if (current_instance == nullptr) { WARN_PRINT("Recording should not be set as active before Godot has initialized."); - recording_active = false; return; } ensure_thread_stopped(); - recording_active = true; current_instance->init(); } else { - recording_active = false; + if (current_instance != nullptr) { + current_instance->is_recording = false; + } } } bool AudioEffectRecord::is_recording_active() const { - return recording_active; + if (current_instance != nullptr) { + return current_instance->is_recording; + } else { + return false; + } } void AudioEffectRecord::set_format(AudioStreamSample::Format p_format) { @@ -289,5 +287,8 @@ void AudioEffectRecord::_bind_methods() { AudioEffectRecord::AudioEffectRecord() { format = AudioStreamSample::FORMAT_16_BITS; - recording_active = false; +} + +AudioEffectRecord::~AudioEffectRecord() { + ensure_thread_stopped(); } diff --git a/servers/audio/effects/audio_effect_record.h b/servers/audio/effects/audio_effect_record.h index ecb74e59d9e..f45e7bbd499 100644 --- a/servers/audio/effects/audio_effect_record.h +++ b/servers/audio/effects/audio_effect_record.h @@ -45,7 +45,6 @@ class AudioEffectRecord; class AudioEffectRecordInstance : public AudioEffectInstance { GDCLASS(AudioEffectRecordInstance, AudioEffectInstance); friend class AudioEffectRecord; - Ref base; bool is_recording; Thread io_thread; @@ -68,9 +67,6 @@ public: void finish(); virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count); virtual bool process_silence() const; - - AudioEffectRecordInstance() {} - ~AudioEffectRecordInstance(); }; class AudioEffectRecord : public AudioEffect { @@ -82,7 +78,6 @@ class AudioEffectRecord : public AudioEffect { IO_BUFFER_SIZE_MS = 1500 }; - bool recording_active; Ref current_instance; AudioStreamSample::Format format; @@ -101,6 +96,7 @@ public: Ref get_recording() const; AudioEffectRecord(); + ~AudioEffectRecord(); }; #endif // AUDIO_EFFECT_RECORD_H