From 07beae98f04308ebcbaa5f4efc2d5e982b2eda22 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Wed, 15 Mar 2023 22:11:02 +0300 Subject: GDScript: Fix false positive `REDUNDANT_AWAIT` warning (cherry picked from commit c0eeb32e38fbd4f582f7a2726e6535614e507205) --- modules/gdscript/gdscript_analyzer.cpp | 2 +- .../analyzer/features/warning_ignore_annotation.gd | 2 +- .../scripts/analyzer/warnings/redundant_await.gd | 53 ++++++++++++++++++++++ .../scripts/analyzer/warnings/redundant_await.out | 37 +++++++++++++++ .../runtime/features/await_without_coroutine.gd | 2 +- 5 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out (limited to 'modules') diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 38d5ae6b77..c233d51801 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2548,7 +2548,7 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) { #ifdef DEBUG_ENABLED GDScriptParser::DataType to_await_type = p_await->to_await->get_datatype(); - if (!(to_await_type.has_no_type() || to_await_type.is_coroutine || to_await_type.builtin_type == Variant::SIGNAL)) { + if (!to_await_type.is_coroutine && !to_await_type.is_variant() && to_await_type.builtin_type != Variant::SIGNAL) { parser->push_warning(p_await, GDScriptWarning::REDUNDANT_AWAIT); } #endif diff --git a/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd b/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd index 4c02fd4b0d..292db30bcd 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_annotation.gd @@ -11,5 +11,5 @@ func test(): print("done") -func regular_func(): +func regular_func() -> int: return 0 diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd new file mode 100644 index 0000000000..f8844d66a7 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.gd @@ -0,0 +1,53 @@ +signal my_signal() + +# CI cannot test async things. +func test_signals(): + await my_signal + var t: Signal = my_signal + await t + +func coroutine() -> void: + @warning_ignore("redundant_await") + await 0 + +func not_coroutine_variant(): + pass + +func not_coroutine_void() -> void: + pass + +func test(): + const CONST_NULL = null + var var_null = null + var var_int: int = 1 + var var_variant: Variant = 1 + var var_array: Array = [1] + + await CONST_NULL + await var_null + await var_int + await var_variant + await var_array[0] + + await coroutine + await coroutine() + await coroutine.call() + await self.coroutine() + await call(&"coroutine") + + await not_coroutine_variant + await not_coroutine_variant() + await self.not_coroutine_variant() + await not_coroutine_variant.call() + await call(&"not_coroutine_variant") + + await not_coroutine_void + await not_coroutine_void() + await self.not_coroutine_void() + await not_coroutine_void.call() + await call(&"not_coroutine_void") + + var callable: Callable = coroutine + await callable + await callable.call() + await callable.get_method() diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out new file mode 100644 index 0000000000..3d251c2906 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/warnings/redundant_await.out @@ -0,0 +1,37 @@ +GDTEST_OK +>> WARNING +>> Line: 26 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 28 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 32 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 38 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 44 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 45 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 46 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 51 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. +>> WARNING +>> Line: 53 +>> REDUNDANT_AWAIT +>> "await" keyword not needed in this case, because the expression isn't a coroutine nor a signal. diff --git a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd index 9da61ab184..1c39073be9 100644 --- a/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd +++ b/modules/gdscript/tests/scripts/runtime/features/await_without_coroutine.gd @@ -4,5 +4,5 @@ func test(): print(await not_coroutine()) -func not_coroutine(): +func not_coroutine() -> String: return "awaited" -- cgit v1.2.3 From b39cbe71b4abd053f2ea86948f3cb6ff6c1c8b9c Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Wed, 15 Mar 2023 13:40:44 +1100 Subject: Fix typo in OpenXR pose orientation check (cherry picked from commit cdd9de28a80079bd3f81a8b004e02e8511a03869) --- modules/openxr/scene/openxr_hand.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/openxr/scene/openxr_hand.cpp b/modules/openxr/scene/openxr_hand.cpp index e4bd2dab52..e341d2b1d4 100644 --- a/modules/openxr/scene/openxr_hand.cpp +++ b/modules/openxr/scene/openxr_hand.cpp @@ -216,7 +216,7 @@ void OpenXRHand::_update_skeleton() { const auto &pose = location.pose; if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) { - if (pose.orientation.x != 0 || pose.orientation.y != 0 || pose.orientation.y != 0 || pose.orientation.w != 0) { + if (pose.orientation.x != 0 || pose.orientation.y != 0 || pose.orientation.z != 0 || pose.orientation.w != 0) { quaternions[i] = Quaternion(pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w); inv_quaternions[i] = quaternions[i].inverse(); -- cgit v1.2.3 From 9f20659c62796184ede59a1ea930e9bf492f0195 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Tue, 7 Mar 2023 09:38:29 -0500 Subject: Fixups to list handling in SceneReplicationConfig Wrong paths were being inserted leading to duplicates / missed properties. (cherry picked from commit 74edbdd4bce8f7a8a6c01ecb6ba5ae74ad6bac10) --- modules/multiplayer/scene_replication_config.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/multiplayer/scene_replication_config.cpp b/modules/multiplayer/scene_replication_config.cpp index f8006228de..b91c755c62 100644 --- a/modules/multiplayer/scene_replication_config.cpp +++ b/modules/multiplayer/scene_replication_config.cpp @@ -51,6 +51,9 @@ bool SceneReplicationConfig::_set(const StringName &p_name, const Variant &p_val ERR_FAIL_INDEX_V(idx, properties.size(), false); ReplicationProperty &prop = properties[idx]; if (what == "sync") { + if ((bool)p_value == prop.sync) { + return true; + } prop.sync = p_value; if (prop.sync) { sync_props.push_back(prop.name); @@ -59,6 +62,9 @@ bool SceneReplicationConfig::_set(const StringName &p_name, const Variant &p_val } return true; } else if (what == "spawn") { + if ((bool)p_value == prop.spawn) { + return true; + } prop.spawn = p_value; if (prop.spawn) { spawn_props.push_back(prop.name); @@ -132,16 +138,18 @@ void SceneReplicationConfig::add_property(const NodePath &p_path, int p_index) { spawn_props.clear(); for (const ReplicationProperty &prop : properties) { if (prop.sync) { - sync_props.push_back(p_path); + sync_props.push_back(prop.name); } if (prop.spawn) { - spawn_props.push_back(p_path); + spawn_props.push_back(prop.name); } } } void SceneReplicationConfig::remove_property(const NodePath &p_path) { properties.erase(p_path); + sync_props.erase(p_path); + spawn_props.erase(p_path); } bool SceneReplicationConfig::has_property(const NodePath &p_path) const { @@ -178,7 +186,7 @@ void SceneReplicationConfig::property_set_spawn(const NodePath &p_path, bool p_e spawn_props.clear(); for (const ReplicationProperty &prop : properties) { if (prop.spawn) { - spawn_props.push_back(p_path); + spawn_props.push_back(prop.name); } } } @@ -199,7 +207,7 @@ void SceneReplicationConfig::property_set_sync(const NodePath &p_path, bool p_en sync_props.clear(); for (const ReplicationProperty &prop : properties) { if (prop.sync) { - sync_props.push_back(p_path); + sync_props.push_back(prop.name); } } } -- cgit v1.2.3 From 493e39860dd5648fc0886b3e59772938158eedab Mon Sep 17 00:00:00 2001 From: Redwarx008 <50837890+Redwarx008@users.noreply.github.com> Date: Sun, 26 Mar 2023 21:14:08 +0800 Subject: C#: Fix Array.AddRange index out of bounds Fix Array.AddRange index out of bounds (cherry picked from commit eb1fb254a649efe128a3d993b7bd31486e9356e1) --- modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index 8598c32760..5163ea5113 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -554,6 +554,7 @@ namespace Godot.Collections // instead of growing it as we add items. if (collection.TryGetNonEnumeratedCount(out int count)) { + int oldCount = Count; Resize(Count + count); using var enumerator = collection.GetEnumerator(); @@ -561,7 +562,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { enumerator.MoveNext(); - this[count + i] = Variant.From(enumerator.Current); + this[oldCount + i] = Variant.From(enumerator.Current); } return; @@ -1578,6 +1579,7 @@ namespace Godot.Collections // instead of growing it as we add items. if (collection.TryGetNonEnumeratedCount(out int count)) { + int oldCount = Count; Resize(Count + count); using var enumerator = collection.GetEnumerator(); @@ -1585,7 +1587,7 @@ namespace Godot.Collections for (int i = 0; i < count; i++) { enumerator.MoveNext(); - this[count + i] = enumerator.Current; + this[oldCount + i] = enumerator.Current; } return; -- cgit v1.2.3 From 4323c8b78ba03c8fef6dfc580c1aa1010ed3096d Mon Sep 17 00:00:00 2001 From: Chris Hutchinson Date: Sat, 11 Feb 2023 23:10:50 -0500 Subject: Replaced operating system alert dialog with a warning log message, toggled by a project setting. Fixes #73141 (cherry picked from commit cb8e91924399948888d80d20c6112df473897183) --- modules/openxr/register_types.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp index c39e49387a..b7d239fc73 100644 --- a/modules/openxr/register_types.cpp +++ b/modules/openxr/register_types.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "register_types.h" +#include "core/config/project_settings.h" #include "main/main.h" #include "openxr_interface.h" @@ -113,10 +114,19 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) { ERR_FAIL_NULL(openxr_api); if (!openxr_api->initialize(Main::get_rendering_driver_name())) { - OS::get_singleton()->alert("OpenXR was requested but failed to start.\n" - "Please check if your HMD is connected.\n" - "When using Windows MR please note that WMR only has DirectX support, make sure SteamVR is your default OpenXR runtime.\n" - "Godot will start in normal mode.\n"); + const char *init_error_message = + "OpenXR was requested but failed to start.\n" + "Please check if your HMD is connected.\n" + "When using Windows MR please note that WMR only has DirectX support, make sure SteamVR is your default OpenXR runtime.\n" + "Godot will start in normal mode.\n"; + + WARN_PRINT(init_error_message); + + bool init_show_startup_alert = GLOBAL_GET("xr/openxr/startup_alert"); + if (init_show_startup_alert) { + OS::get_singleton()->alert(init_error_message); + } + memdelete(openxr_api); openxr_api = nullptr; return; -- cgit v1.2.3