summaryrefslogtreecommitdiff
path: root/modules/openxr/action_map
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2022-04-20 11:00:58 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2022-04-20 11:00:58 +0800
commit925e8c8f3ea915470484f096847ec4abd9cc6839 (patch)
tree0c40dbcf046446dac653aeca382d415187b07cc2 /modules/openxr/action_map
parent7f384886ce65fb5deead17a3604a9f0b8917a9ee (diff)
Validate input in OpenXR array setter
Diffstat (limited to 'modules/openxr/action_map')
-rw-r--r--modules/openxr/action_map/openxr_action_map.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/modules/openxr/action_map/openxr_action_map.cpp b/modules/openxr/action_map/openxr_action_map.cpp
index 2ba33419d7..366e131369 100644
--- a/modules/openxr/action_map/openxr_action_map.cpp
+++ b/modules/openxr/action_map/openxr_action_map.cpp
@@ -55,7 +55,14 @@ void OpenXRActionMap::_bind_methods() {
}
void OpenXRActionMap::set_action_sets(Array p_action_sets) {
- action_sets = p_action_sets;
+ action_sets.clear();
+
+ for (int i = 0; i < p_action_sets.size(); i++) {
+ Ref<OpenXRActionSet> action_set = p_action_sets[i];
+ if (action_set.is_valid() && action_sets.find(action_set) == -1) {
+ action_sets.push_back(action_set);
+ }
+ }
}
Array OpenXRActionMap::get_action_sets() const {
@@ -99,7 +106,14 @@ void OpenXRActionMap::remove_action_set(Ref<OpenXRActionSet> p_action_set) {
}
void OpenXRActionMap::set_interaction_profiles(Array p_interaction_profiles) {
- interaction_profiles = p_interaction_profiles;
+ interaction_profiles.clear();
+
+ for (int i = 0; i < p_interaction_profiles.size(); i++) {
+ Ref<OpenXRInteractionProfile> interaction_profile = p_interaction_profiles[i];
+ if (interaction_profile.is_valid() && interaction_profiles.find(interaction_profile) == -1) {
+ interaction_profiles.push_back(interaction_profile);
+ }
+ }
}
Array OpenXRActionMap::get_interaction_profiles() const {