Skip to content

Commit

Permalink
Merge pull request #81374 from akien-mga/3.5-cherrypicks
Browse files Browse the repository at this point in the history
Cherry-picks for the 3.5 branch (future 3.5.3) - 3rd batch
  • Loading branch information
akien-mga authored Sep 6, 2023
2 parents 6cedbcc + 2eaa385 commit fc32e06
Show file tree
Hide file tree
Showing 23 changed files with 179 additions and 72 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 🤖 Android Builds
on: [push, pull_request]
on:
workflow_call:

# Global Settings
env:
Expand All @@ -17,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
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ios_builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 🍏 iOS Builds
on: [push, pull_request]
on:
workflow_call:

# Global Settings
env:
Expand All @@ -17,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
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/javascript_builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 🌐 JavaScript Builds
on: [push, pull_request]
on:
workflow_call:

# Global Settings
env:
Expand All @@ -19,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
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 🐧 Linux Builds
on: [push, pull_request]
on:
workflow_call:

# Global Settings
env:
Expand Down Expand Up @@ -48,7 +49,7 @@ jobs:
artifact: true

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Linux dependencies
shell: bash
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 🍎 macOS Builds
on: [push, pull_request]
on:
workflow_call:

# Global Settings
env:
Expand Down Expand Up @@ -31,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
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/runner.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions .github/workflows/server_builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: ☁ Server Builds
on: [push, pull_request]
on:
workflow_call:

# Global Settings
env:
Expand Down Expand Up @@ -30,7 +31,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Linux dependencies
shell: bash
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,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
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,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
Expand Down
27 changes: 8 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -246,9 +232,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/
Expand All @@ -258,6 +241,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/

Expand Down
3 changes: 3 additions & 0 deletions core/class_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class ClassDB {
template <class T>
static void register_class() {
GLOBAL_LOCK_FUNCTION;
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
Expand All @@ -182,6 +183,7 @@ class ClassDB {
template <class T>
static void register_virtual_class() {
GLOBAL_LOCK_FUNCTION;
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
Expand All @@ -198,6 +200,7 @@ class ClassDB {
template <class T>
static void register_custom_instance_class() {
GLOBAL_LOCK_FUNCTION;
static_assert(TypesAreSame<typename T::self_type, T>::value, "Class not declared properly, please use GDCLASS.");
T::initialize_class();
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
Expand Down
6 changes: 6 additions & 0 deletions core/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions core/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ private:
friend class ClassDB; \
\
public: \
typedef m_class self_type; \
virtual String get_class() const { \
return String(#m_class); \
} \
Expand Down Expand Up @@ -405,6 +406,8 @@ class ObjectRC;

class Object {
public:
typedef Object self_type;

enum ConnectFlags {

CONNECT_DEFERRED = 1,
Expand Down
32 changes: 27 additions & 5 deletions core/variant_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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<Variant> keys;
Expand All @@ -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 {
Expand All @@ -1733,14 +1747,21 @@ 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();
for (int i = 0; i < len; i++) {
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, " ]");

Expand Down Expand Up @@ -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: {
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/variant_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class VariantWriter {
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);
};

Expand Down
Loading

0 comments on commit fc32e06

Please sign in to comment.