From 3f89287ddbe1625bb00f92415950db6096a79ce0 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 18 May 2021 15:01:21 +0800 Subject: [PATCH 01/13] Fix XMLParser behavior for comments and premature endings (cherry picked from commit 549ad70760e96828dadc98ad47bd4788e14947f2) --- core/io/xml_parser.cpp | 97 ++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 4e63566e970..a4715a229c1 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -132,7 +132,7 @@ void XMLParser::_parse_closing_xml_element() { ++P; const char *pBeginClose = P; - while (*P != '>') { + while (*P && *P != '>') { ++P; } @@ -140,7 +140,10 @@ void XMLParser::_parse_closing_xml_element() { #ifdef DEBUG_XML print_line("XML CLOSE: " + node_name); #endif - ++P; + + if (*P) { + ++P; + } } void XMLParser::_ignore_definition() { @@ -148,11 +151,14 @@ void XMLParser::_ignore_definition() { char *F = P; // move until end marked with '>' reached - while (*P != '>') { + while (*P && *P != '>') { ++P; } node_name.parse_utf8(F, P - F); - ++P; + + if (*P) { + ++P; + } } bool XMLParser::_parse_cdata() { @@ -170,6 +176,7 @@ bool XMLParser::_parse_cdata() { } if (!*P) { + node_name = ""; return true; } @@ -188,10 +195,9 @@ bool XMLParser::_parse_cdata() { } if (cDataEnd) { - node_name = String::utf8(cDataBegin, (int)(cDataEnd - cDataBegin)); - } else { - node_name = ""; + cDataEnd = P; } + node_name = String::utf8(cDataBegin, (int)(cDataEnd - cDataBegin)); #ifdef DEBUG_XML print_line("XML CDATA: " + node_name); #endif @@ -203,24 +209,45 @@ void XMLParser::_parse_comment() { node_type = NODE_COMMENT; P += 1; - char *pCommentBegin = P; + char *pEndOfInput = data + length; + char *pCommentBegin; + char *pCommentEnd; - int count = 1; + if (P + 1 < pEndOfInput && P[0] == '-' && P[1] == '-') { + // Comment, use '-->' as end. + pCommentBegin = P + 2; + for (pCommentEnd = pCommentBegin; pCommentEnd + 2 < pEndOfInput; pCommentEnd++) { + if (pCommentEnd[0] == '-' && pCommentEnd[1] == '-' && pCommentEnd[2] == '>') { + break; + } + } + if (pCommentEnd + 2 < pEndOfInput) { + P = pCommentEnd + 3; + } else { + P = pCommentEnd = pEndOfInput; + } + } else { + // Like document type definition, match angle brackets. + pCommentBegin = P; - // move until end of comment reached - while (count) { - if (*P == '>') { - --count; - } else if (*P == '<') { - ++count; + int count = 1; + while (*P && count) { + if (*P == '>') { + --count; + } else if (*P == '<') { + ++count; + } + ++P; } - ++P; + if (count) { + pCommentEnd = P; + } else { + pCommentEnd = P - 1; + } } - P -= 3; - node_name = String::utf8(pCommentBegin + 2, (int)(P - pCommentBegin - 2)); - P += 3; + node_name = String::utf8(pCommentBegin, (int)(pCommentEnd - pCommentBegin)); #ifdef DEBUG_XML print_line("XML COMMENT: " + node_name); #endif @@ -235,14 +262,14 @@ void XMLParser::_parse_opening_xml_element() { const char *startName = P; // find end of element - while (*P != '>' && !_is_white_space(*P)) { + while (*P && *P != '>' && !_is_white_space(*P)) { ++P; } const char *endName = P; // find attributes - while (*P != '>') { + while (*P && *P != '>') { if (_is_white_space(*P)) { ++P; } else { @@ -252,10 +279,14 @@ void XMLParser::_parse_opening_xml_element() { // read the attribute names const char *attributeNameBegin = P; - while (!_is_white_space(*P) && *P != '=') { + while (*P && !_is_white_space(*P) && *P != '=') { ++P; } + if (!*P) { + break; + } + const char *attributeNameEnd = P; ++P; @@ -266,7 +297,7 @@ void XMLParser::_parse_opening_xml_element() { } if (!*P) { // malformatted xml file - return; + break; } const char attributeQuoteChar = *P; @@ -278,12 +309,10 @@ void XMLParser::_parse_opening_xml_element() { ++P; } - if (!*P) { // malformatted xml file - return; - } - const char *attributeValueEnd = P; - ++P; + if (*P) { + ++P; + } Attribute attr; attr.name = String::utf8(attributeNameBegin, @@ -315,7 +344,9 @@ void XMLParser::_parse_opening_xml_element() { print_line("XML OPEN: " + node_name); #endif - ++P; + if (*P) { + ++P; + } } void XMLParser::_parse_current_node() { @@ -327,10 +358,6 @@ void XMLParser::_parse_current_node() { ++P; } - if (!*P) { - return; - } - if (P - start > 0) { // we found some text, store it if (_set_text(start, P)) { @@ -338,6 +365,10 @@ void XMLParser::_parse_current_node() { } } + if (!*P) { + return; + } + ++P; // based on current token, parse and report next element From 12236d28687db984d5d9dd3f247936b93195ed0a Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 7 May 2021 19:02:35 +0200 Subject: [PATCH 02/13] Only allow absolute paths in XDG environment variables The XDG Base Directory specification does not allow using relative paths (which broke things in Godot anyway). If a relative path is detected, it should be ignored. (cherry picked from commits 011a99316ab8c0e96971aebd9ba995313867fe17 and 0e1d45b210d0e5924b279419d9bba188f557e329) --- platform/osx/os_osx.mm | 40 +++++++++++++++++++++---------- platform/windows/os_windows.cpp | 42 ++++++++++++++++++++++----------- platform/x11/os_x11.cpp | 42 +++++++++++++++++++++------------ 3 files changed, 82 insertions(+), 42 deletions(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 325aee8ad43..cdc9d0e84a9 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -2238,31 +2238,45 @@ MainLoop *OS_OSX::get_main_loop() const { } String OS_OSX::get_config_path() const { + // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_CONFIG_HOME")) { - return get_environment("XDG_CONFIG_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file("Library/Application Support"); - } else { - return "."; + if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + return get_environment("XDG_CONFIG_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Library/Application Support` or `.` per the XDG Base Directory specification."); + } } + if (has_environment("HOME")) { + return get_environment("HOME").plus_file("Library/Application Support"); + } + return "."; } String OS_OSX::get_data_path() const { + // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_DATA_HOME")) { - return get_environment("XDG_DATA_HOME"); - } else { - return get_config_path(); + if (get_environment("XDG_DATA_HOME").is_abs_path()) { + return get_environment("XDG_DATA_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification."); + } } + return get_config_path(); } String OS_OSX::get_cache_path() const { + // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on macOS as well. if (has_environment("XDG_CACHE_HOME")) { - return get_environment("XDG_CACHE_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file("Library/Caches"); - } else { - return get_config_path(); + if (get_environment("XDG_CACHE_HOME").is_abs_path()) { + return get_environment("XDG_CACHE_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/Libary/Caches` or `get_config_path()` per the XDG Base Directory specification."); + } } + if (has_environment("HOME")) { + return get_environment("HOME").plus_file("Library/Caches"); + } + return get_config_path(); } String OS_OSX::get_bundle_resource_dir() const { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index c013e562462..952c83179b9 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -3316,31 +3316,45 @@ MainLoop *OS_Windows::get_main_loop() const { } String OS_Windows::get_config_path() const { - if (has_environment("XDG_CONFIG_HOME")) { // unlikely, but after all why not? - return get_environment("XDG_CONFIG_HOME"); - } else if (has_environment("APPDATA")) { - return get_environment("APPDATA"); - } else { - return "."; + // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. + if (has_environment("XDG_CONFIG_HOME")) { + if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + return get_environment("XDG_CONFIG_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `%APPDATA%` or `.` per the XDG Base Directory specification."); + } } + if (has_environment("APPDATA")) { + return get_environment("APPDATA"); + } + return "."; } String OS_Windows::get_data_path() const { + // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. if (has_environment("XDG_DATA_HOME")) { - return get_environment("XDG_DATA_HOME"); - } else { - return get_config_path(); + if (get_environment("XDG_DATA_HOME").is_abs_path()) { + return get_environment("XDG_DATA_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `get_config_path()` per the XDG Base Directory specification."); + } } + return get_config_path(); } String OS_Windows::get_cache_path() const { + // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well. if (has_environment("XDG_CACHE_HOME")) { - return get_environment("XDG_CACHE_HOME"); - } else if (has_environment("TEMP")) { - return get_environment("TEMP"); - } else { - return get_config_path(); + if (get_environment("XDG_CACHE_HOME").is_abs_path()) { + return get_environment("XDG_CACHE_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `%TEMP%` or `get_config_path()` per the XDG Base Directory specification."); + } } + if (has_environment("TEMP")) { + return get_environment("TEMP"); + } + return get_config_path(); } // Get properly capitalized engine name for system paths diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 1a888ac504f..7a5c80e2cb2 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -3208,32 +3208,44 @@ bool OS_X11::_check_internal_feature_support(const String &p_feature) { String OS_X11::get_config_path() const { if (has_environment("XDG_CONFIG_HOME")) { - return get_environment("XDG_CONFIG_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".config"); - } else { - return "."; + if (get_environment("XDG_CONFIG_HOME").is_abs_path()) { + return get_environment("XDG_CONFIG_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CONFIG_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.config` or `.` per the XDG Base Directory specification."); + } } + if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".config"); + } + return "."; } String OS_X11::get_data_path() const { if (has_environment("XDG_DATA_HOME")) { - return get_environment("XDG_DATA_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".local/share"); - } else { - return get_config_path(); + if (get_environment("XDG_DATA_HOME").is_abs_path()) { + return get_environment("XDG_DATA_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_DATA_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.local/share` or `get_config_path()` per the XDG Base Directory specification."); + } } + if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".local/share"); + } + return get_config_path(); } String OS_X11::get_cache_path() const { if (has_environment("XDG_CACHE_HOME")) { - return get_environment("XDG_CACHE_HOME"); - } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".cache"); - } else { - return get_config_path(); + if (get_environment("XDG_CACHE_HOME").is_abs_path()) { + return get_environment("XDG_CACHE_HOME"); + } else { + WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `$HOME/.cache` or `get_config_path()` per the XDG Base Directory specification."); + } } + if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".cache"); + } + return get_config_path(); } String OS_X11::get_system_dir(SystemDir p_dir) const { From 2c400a7aae0c6a3e7fdfeff5aa416f9e3c2ab0b2 Mon Sep 17 00:00:00 2001 From: jfons Date: Thu, 20 May 2021 16:28:38 +0200 Subject: [PATCH 03/13] Fix swapped front/rear directions in viewport rotation control. (cherry picked from commit e70e33ddcf02fcb87d7e764280f464c0c8405f29) --- editor/plugins/spatial_editor_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index e7c7e71c4b3..9e88c42ab12 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -80,10 +80,10 @@ void ViewportRotationControl::_notification(int p_what) { axis_menu_options.clear(); axis_menu_options.push_back(SpatialEditorViewport::VIEW_RIGHT); axis_menu_options.push_back(SpatialEditorViewport::VIEW_TOP); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_FRONT); + axis_menu_options.push_back(SpatialEditorViewport::VIEW_REAR); axis_menu_options.push_back(SpatialEditorViewport::VIEW_LEFT); axis_menu_options.push_back(SpatialEditorViewport::VIEW_BOTTOM); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_REAR); + axis_menu_options.push_back(SpatialEditorViewport::VIEW_FRONT); axis_colors.clear(); axis_colors.push_back(get_color("axis_x_color", "Editor")); From d5b6cb4639f2f297d9cc7761984de2b6785ba993 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Thu, 20 May 2021 14:08:59 -0700 Subject: [PATCH 04/13] When one invalid image fails, it should only fail that single image. Move to a more graceful degradation 3d asset import model. (cherry picked from commit a81f4dd5a7a92c2e7c7fc3185eeea745bd41cb5b) --- editor/import/editor_scene_importer_gltf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index df220935f52..3bda1b89c61 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1451,8 +1451,11 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } } - ERR_FAIL_COND_V_MSG(img.is_null(), ERR_FILE_CORRUPT, - vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype)); + if (img.is_null()) { + ERR_PRINT(vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype)); + state.images.push_back(Ref()); + continue; + } Ref t; t.instance(); From 66a8654963e697d96fc1f09db8ae00d05fd3841d Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 20 May 2021 22:25:58 +0200 Subject: [PATCH 05/13] Remove `#ifdef` catering to MSVC 2012 and earlier in `math_funcs.h` For the `master` branch, the minimum supported MSVC version is now MSVC 2017 (with MSVC 2019 being recommended). (cherry picked from commit b57d9c8005067d149fe34392b19a0520352cd5c6) --- core/math/math_funcs.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 813d5362c34..a65b967455d 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -376,28 +376,10 @@ public: return u.d; } - //this function should be as fast as possible and rounding mode should not matter + // This function should be as fast as possible and rounding mode should not matter. static _ALWAYS_INLINE_ int fast_ftoi(float a) { - static int b; - -#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603) || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP // windows 8 phone? - b = (int)((a > 0.0) ? (a + 0.5) : (a - 0.5)); - -#elif defined(_MSC_VER) && _MSC_VER < 1800 - __asm fld a __asm fistp b - /*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) - // use AT&T inline assembly style, document that - // we use memory as output (=m) and input (m) - __asm__ __volatile__ ( - "flds %1 \n\t" - "fistpl %0 \n\t" - : "=m" (b) - : "m" (a));*/ - -#else - b = lrintf(a); //assuming everything but msvc 2012 or earlier has lrint -#endif - return b; + // Assuming every supported compiler has `lrint()`. + return lrintf(a); } static _ALWAYS_INLINE_ uint32_t halfbits_to_floatbits(uint16_t h) { From ebfba19b593de997e0a5cacd24ad0785dd9d4cde Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 20 May 2021 07:18:53 -0400 Subject: [PATCH 06/13] Use global scope round method for rounding (cherry picked from commit b01aa69c80aa8c953d9ec885238c7cfd8063019b) --- core/math/math_funcs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index a65b967455d..3e6d861f083 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -255,8 +255,8 @@ public: static _ALWAYS_INLINE_ double db2linear(double p_db) { return Math::exp(p_db * 0.11512925464970228420089957273422); } static _ALWAYS_INLINE_ float db2linear(float p_db) { return Math::exp(p_db * 0.11512925464970228420089957273422); } - static _ALWAYS_INLINE_ double round(double p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); } - static _ALWAYS_INLINE_ float round(float p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); } + static _ALWAYS_INLINE_ double round(double p_val) { return ::round(p_val); } + static _ALWAYS_INLINE_ float round(float p_val) { return ::roundf(p_val); } static _ALWAYS_INLINE_ int64_t wrapi(int64_t value, int64_t min, int64_t max) { int64_t range = max - min; From ec6a3a0d0c5b49185a4cc72ccd115ead90380edb Mon Sep 17 00:00:00 2001 From: Lyuma Date: Thu, 20 May 2021 19:12:16 -0700 Subject: [PATCH 07/13] gltf: Fail gracefully when a mesh instance fails. (cherry picked from commit 5a9eee6b1a2f633935cfcbbe5f938263dd092e8e) --- editor/import/editor_scene_importer_gltf.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 3bda1b89c61..2c0e5ab76d1 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -3138,13 +3138,15 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial const GLTFSkinIndex skin_i = node->skin; Map::Element *mi_element = state.scene_nodes.find(node_i); + ERR_CONTINUE_MSG(mi_element == nullptr, vformat("Unable to find node %d", node_i)); + MeshInstance *mi = Object::cast_to(mi_element->get()); - ERR_FAIL_COND(mi == nullptr); + ERR_CONTINUE_MSG(mi == nullptr, vformat("Unable to cast node %d of type %s to MeshInstance", node_i, mi_element->get()->get_class_name())); const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton; const GLTFSkeleton &gltf_skeleton = state.skeletons[skel_i]; Skeleton *skeleton = gltf_skeleton.godot_skeleton; - ERR_FAIL_COND(skeleton == nullptr); + ERR_CONTINUE_MSG(skeleton == nullptr, vformat("Unable to find Skeleton for node %d skin %d", node_i, skin_i)); mi->get_parent()->remove_child(mi); skeleton->add_child(mi); From a0b8c24d927c7d7cf99935776444558eac3f5ad8 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Thu, 20 May 2021 20:26:11 -0700 Subject: [PATCH 08/13] Fix incorrect skin deduplication when using named binds (cherry picked from commit 60f620411e337635ecbc4628e3df81f11ac25760) --- editor/import/editor_scene_importer_gltf.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 2c0e5ab76d1..1398be5980d 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2359,6 +2359,9 @@ bool EditorSceneImporterGLTF::_skins_are_same(const Ref &skin_a, const Ref if (skin_a->get_bind_bone(i) != skin_b->get_bind_bone(i)) { return false; } + if (skin_a->get_bind_name(i) != skin_b->get_bind_name(i)) { + return false; + } Transform a_xform = skin_a->get_bind_pose(i); Transform b_xform = skin_b->get_bind_pose(i); From 379ecd532a17307974f0a739df67e2e250bebce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 20 May 2021 16:09:06 +0200 Subject: [PATCH 09/13] Dist: Add macOS entitlements files for editor code signing These are the entitlements we define for official macOS editor builds since Godot 3.3. Users making custom builds of the engine can use those files with `codesign` to sign their own builds. E.g.: ``` codesign --force --timestamp \ --options=runtime --entitlements editor.entitlements \ -s -v osx_template.app ``` (cherry picked from commit 6999e332e4d77db2cf99648e5a83798b583367ce) --- misc/dist/osx/editor.entitlements | 12 ++++++++++++ misc/dist/osx/editor_mono.entitlements | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 misc/dist/osx/editor.entitlements create mode 100644 misc/dist/osx/editor_mono.entitlements diff --git a/misc/dist/osx/editor.entitlements b/misc/dist/osx/editor.entitlements new file mode 100644 index 00000000000..5496f65dcc3 --- /dev/null +++ b/misc/dist/osx/editor.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.device.audio-input + + com.apple.security.device.camera + + com.apple.security.cs.disable-library-validation + + + diff --git a/misc/dist/osx/editor_mono.entitlements b/misc/dist/osx/editor_mono.entitlements new file mode 100644 index 00000000000..c61c287652f --- /dev/null +++ b/misc/dist/osx/editor_mono.entitlements @@ -0,0 +1,18 @@ + + + + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-library-validation + + com.apple.security.device.audio-input + + com.apple.security.device.camera + + + From 5e735a9c1f6b74f12ee17935945843dbad44d870 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 16 May 2021 00:29:56 +0200 Subject: [PATCH 10/13] Tweak highlight color in the editor Find in Files dialog The new color is more visible against dark backgrounds. (cherry picked from commit 82570dec9032c2ab98da39072c1a964a2b74ca0e) --- editor/find_in_files.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 4c704022ceb..606f210ce3b 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -707,8 +707,10 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { match_rect.position.y += 1 * EDSCALE; match_rect.size.y -= 2 * EDSCALE; - _results_display->draw_rect(match_rect, Color(0, 0, 0, 0.5)); - // Text is drawn by Tree already + // Use the inverted accent color to help match rectangles stand out even on the currently selected line. + _results_display->draw_rect(match_rect, get_color("accent_color", "Editor").inverted() * Color(1, 1, 1, 0.5)); + + // Text is drawn by Tree already. } void FindInFilesPanel::_on_item_edited() { From 8063d69abda36563ce8500be54a14551ee34520d Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 12 May 2021 17:07:53 +0200 Subject: [PATCH 11/13] List "Argument" for each extra bind argument in the connect dialog This makes the dialog more explicit. (cherry picked from commit 994dd314e021d7699e81a5ae3c5bc51f1b247023) --- editor/connections_dialog.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 39d8d53204c..5bb216d4778 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -65,8 +65,8 @@ public: bool _set(const StringName &p_name, const Variant &p_value) { String name = p_name; - if (name.begins_with("bind/")) { - int which = name.get_slice("/", 1).to_int() - 1; + if (name.begins_with("bind/argument_")) { + int which = name.get_slice("_", 1).to_int() - 1; ERR_FAIL_INDEX_V(which, params.size(), false); params.write[which] = p_value; } else { @@ -79,8 +79,8 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { String name = p_name; - if (name.begins_with("bind/")) { - int which = name.get_slice("/", 1).to_int() - 1; + if (name.begins_with("bind/argument_")) { + int which = name.get_slice("_", 1).to_int() - 1; ERR_FAIL_INDEX_V(which, params.size(), false); r_ret = params[which]; } else { @@ -92,7 +92,7 @@ public: void _get_property_list(List *p_list) const { for (int i = 0; i < params.size(); i++) { - p_list->push_back(PropertyInfo(params[i].get_type(), "bind/" + itos(i + 1))); + p_list->push_back(PropertyInfo(params[i].get_type(), "bind/argument_" + itos(i + 1))); } } From a26bed52c032f93599bc1dad92335beff1521884 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 21 May 2021 15:40:03 +0800 Subject: [PATCH 12/13] Fix editor crash when exporting profiler data (cherry picked from commit be79bdc8ab5bbce66d408d9256d5dfa431b5cf08) --- editor/editor_profiler.cpp | 55 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index f625c69cc0e..27009453143 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -613,23 +613,35 @@ Vector> EditorProfiler::get_data_as_csv() const { return res; } - // signatures - Vector signatures; - const Vector &categories = frame_metrics[0].categories; - - for (int j = 0; j < categories.size(); j++) { - const EditorProfiler::Metric::Category &c = categories[j]; - signatures.push_back(c.signature); - - for (int k = 0; k < c.items.size(); k++) { - signatures.push_back(c.items[k].signature); + // Different metrics may contain different number of categories. + Set possible_signatures; + for (int i = 0; i < frame_metrics.size(); i++) { + const Metric &m = frame_metrics[i]; + if (!m.valid) { + continue; } + for (Map::Element *E = m.category_ptrs.front(); E; E = E->next()) { + possible_signatures.insert(E->key()); + } + for (Map::Element *E = m.item_ptrs.front(); E; E = E->next()) { + possible_signatures.insert(E->key()); + } + } + + // Generate CSV header and cache indices. + Map sig_map; + Vector signatures; + signatures.resize(possible_signatures.size()); + int sig_index = 0; + for (const Set::Element *E = possible_signatures.front(); E; E = E->next()) { + signatures.write[sig_index] = E->get(); + sig_map[E->get()] = sig_index; + sig_index++; } res.push_back(signatures); // values Vector values; - values.resize(signatures.size()); int index = last_metric; @@ -640,20 +652,23 @@ Vector> EditorProfiler::get_data_as_csv() const { index = 0; } - if (!frame_metrics[index].valid) { + const Metric &m = frame_metrics[index]; + + if (!m.valid) { continue; } - int it = 0; - const Vector &frame_cat = frame_metrics[index].categories; - for (int j = 0; j < frame_cat.size(); j++) { - const EditorProfiler::Metric::Category &c = frame_cat[j]; - values.write[it++] = String::num_real(c.total_time); + // Don't keep old values since there may be empty cells. + values.clear(); + values.resize(possible_signatures.size()); - for (int k = 0; k < c.items.size(); k++) { - values.write[it++] = String::num_real(c.items[k].total); - } + for (Map::Element *E = m.category_ptrs.front(); E; E = E->next()) { + values.write[sig_map[E->key()]] = String::num_real(E->value()->total_time); } + for (Map::Element *E = m.item_ptrs.front(); E; E = E->next()) { + values.write[sig_map[E->key()]] = String::num_real(E->value()->total); + } + res.push_back(values); } From cf47129f9a3e54c8b8c92f3cde4d893abb0cc85f Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 21 May 2021 17:12:13 +0800 Subject: [PATCH 13/13] Fix STL to Godot type convertion of polypartition (cherry picked from commit d16bef8b55e6c978da44ea3c4b0822340e15027c) --- thirdparty/misc/triangulator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/thirdparty/misc/triangulator.cpp b/thirdparty/misc/triangulator.cpp index 75b2b064c4a..6710f592408 100644 --- a/thirdparty/misc/triangulator.cpp +++ b/thirdparty/misc/triangulator.cpp @@ -1166,7 +1166,7 @@ int TriangulatorPartition::MonotonePartition(List *inpolys, Li newedge.p1 = v->p; newedge.p2 = v->p; edgeIter = edgeTree.lower_bound(newedge); - if(edgeIter == edgeTree.front()) { + if(edgeIter == nullptr || edgeIter == edgeTree.front()) { error = true; break; } @@ -1202,7 +1202,7 @@ int TriangulatorPartition::MonotonePartition(List *inpolys, Li newedge.p1 = v->p; newedge.p2 = v->p; edgeIter = edgeTree.lower_bound(newedge); - if(edgeIter == edgeTree.front()) { + if(edgeIter == nullptr || edgeIter == edgeTree.front()) { error = true; break; } @@ -1241,7 +1241,7 @@ int TriangulatorPartition::MonotonePartition(List *inpolys, Li newedge.p1 = v->p; newedge.p2 = v->p; edgeIter = edgeTree.lower_bound(newedge); - if(edgeIter == edgeTree.front()) { + if(edgeIter == nullptr || edgeIter == edgeTree.front()) { error = true; break; }