From 70a8761deb3a8d682f091625a64fbceb2ef26a8c Mon Sep 17 00:00:00 2001 From: David Snopek Date: Thu, 22 Aug 2024 13:03:05 -0500 Subject: [PATCH] Fix crash when calling OpenXRAPI::get_hand_tracker() and hand-tracking is disabled (cherry picked from commit 11dd1f52aeb10e3fb8f236e2e5e050c280764fb9) --- modules/openxr/openxr_api.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index 98e54841578..5002d40061b 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -1733,8 +1733,12 @@ void OpenXRAPI::cleanup_extension_wrappers() { XrHandTrackerEXT OpenXRAPI::get_hand_tracker(int p_hand_index) { ERR_FAIL_INDEX_V(p_hand_index, OpenXRHandTrackingExtension::HandTrackedHands::OPENXR_MAX_TRACKED_HANDS, XR_NULL_HANDLE); + + OpenXRHandTrackingExtension *hand_tracking = OpenXRHandTrackingExtension::get_singleton(); + ERR_FAIL_NULL_V(hand_tracking, XR_NULL_HANDLE); + OpenXRHandTrackingExtension::HandTrackedHands hand = static_cast(p_hand_index); - return OpenXRHandTrackingExtension::get_singleton()->get_hand_tracker(hand)->hand_tracker; + return hand_tracking->get_hand_tracker(hand)->hand_tracker; } Size2 OpenXRAPI::get_recommended_target_size() {