Merge pull request #81 from Schmarni-Dev/crash_on_session_create_no_instance_fix

fix panic when trying to start a session without an instance
This commit is contained in:
Schmarni
2024-03-22 19:44:00 +01:00
committed by GitHub

View File

@@ -176,12 +176,12 @@ pub(crate) struct CleanupXrData;
fn start_xr_session( fn start_xr_session(
mut commands: Commands, mut commands: Commands,
mut status: ResMut<XrStatus>, mut status: ResMut<XrStatus>,
instance: Res<XrInstance>, instance: Option<Res<XrInstance>>,
primary_window: Query<&RawHandleWrapper, With<PrimaryWindow>>, primary_window: Query<&RawHandleWrapper, With<PrimaryWindow>>,
setup_info: NonSend<OXrSessionSetupInfo>, setup_info: Option<NonSend<OXrSessionSetupInfo>>,
render_device: Res<RenderDevice>, render_device: Option<Res<RenderDevice>>,
render_adapter: Res<RenderAdapter>, render_adapter: Option<Res<RenderAdapter>>,
render_instance: Res<RenderInstance>, render_instance: Option<Res<RenderInstance>>,
) { ) {
info!("start Session"); info!("start Session");
match *status { match *status {
@@ -199,6 +199,23 @@ fn start_xr_session(
return; return;
} }
} }
let (
Some(instance),
Some(setup_info),
Some(render_device),
Some(render_adapter),
Some(render_instance),
) = (
instance,
setup_info,
render_device,
render_adapter,
render_instance,
)
else {
error!("Missing resources after passing status check");
return;
};
let ( let (
xr_session, xr_session,
xr_resolution, xr_resolution,