Skip to content

Commit

Permalink
Merge pull request #81 from Schmarni-Dev/crash_on_session_create_no_i…
Browse files Browse the repository at this point in the history
…nstance_fix

fix panic when trying to start a session without an instance
  • Loading branch information
Schmarni-Dev authored Mar 22, 2024
2 parents cda25f4 + 92a0563 commit c6d0686
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/xr_init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ pub(crate) struct CleanupXrData;
fn start_xr_session(
mut commands: Commands,
mut status: ResMut<XrStatus>,
instance: Res<XrInstance>,
instance: Option<Res<XrInstance>>,
primary_window: Query<&RawHandleWrapper, With<PrimaryWindow>>,
setup_info: NonSend<OXrSessionSetupInfo>,
render_device: Res<RenderDevice>,
render_adapter: Res<RenderAdapter>,
render_instance: Res<RenderInstance>,
setup_info: Option<NonSend<OXrSessionSetupInfo>>,
render_device: Option<Res<RenderDevice>>,
render_adapter: Option<Res<RenderAdapter>>,
render_instance: Option<Res<RenderInstance>>,
) {
info!("start Session");
match *status {
Expand All @@ -199,6 +199,23 @@ fn start_xr_session(
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 (
xr_session,
xr_resolution,
Expand Down

0 comments on commit c6d0686

Please sign in to comment.