Skip to content

Commit

Permalink
Fix crash when one of multiple windows is closed (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
Plonq authored Mar 8, 2024
1 parent 44784db commit 51f55e4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,12 @@ fn active_viewport_data(
has_input = true;
// First check if cursor is in the same window as this camera
if let RenderTarget::Window(win_ref) = camera.target {
let window = match win_ref {
WindowRef::Primary => primary_windows
.get_single()
.expect("Must exist, since the camera is referencing it"),
WindowRef::Entity(entity) => other_windows
.get(entity)
.expect("Must exist, since the camera is referencing it"),
let Some(window) = (match win_ref {
WindowRef::Primary => primary_windows.get_single().ok(),
WindowRef::Entity(entity) => other_windows.get(entity).ok(),
}) else {
// Window does not exist - maybe it was closed and the camera not cleaned up
continue;
};

// Is the cursor/touch in this window?
Expand Down

0 comments on commit 51f55e4

Please sign in to comment.