diff --git a/CHANGELOG.md b/CHANGELOG.md index 167a1bb5..893c0573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # UNRELEASED +- Fixed: replaced uses of `.insert` with `.try_insert`, where they could potentially panic. - Fixed: replace all `.single` calls with matched `.get_single` calls to avoid crashing in environments where there is no window available - Fixed: sprite picking depth is now consistent with other picking backends. diff --git a/backends/bevy_picking_egui/src/lib.rs b/backends/bevy_picking_egui/src/lib.rs index 07be445d..6ecad457 100644 --- a/backends/bevy_picking_egui/src/lib.rs +++ b/backends/bevy_picking_egui/src/lib.rs @@ -67,7 +67,7 @@ pub fn update_settings( .remove::(), false => commands .entity(entity) - .insert(bevy_picking_selection::NoDeselect), + .try_insert(bevy_picking_selection::NoDeselect), }; } } diff --git a/crates/bevy_picking_core/src/focus.rs b/crates/bevy_picking_core/src/focus.rs index ac932ce8..416ec78f 100644 --- a/crates/bevy_picking_core/src/focus.rs +++ b/crates/bevy_picking_core/src/focus.rs @@ -216,7 +216,7 @@ pub fn update_interactions( if let Ok(mut interaction) = interact.get_mut(hovered_entity) { *interaction = new_interaction; } else if let Some(mut entity_commands) = commands.get_entity(hovered_entity) { - entity_commands.insert(new_interaction); + entity_commands.try_insert(new_interaction); } } } diff --git a/crates/bevy_picking_highlight/src/lib.rs b/crates/bevy_picking_highlight/src/lib.rs index ea53251f..5ebff787 100644 --- a/crates/bevy_picking_highlight/src/lib.rs +++ b/crates/bevy_picking_highlight/src/lib.rs @@ -288,7 +288,7 @@ pub fn get_initial_highlight_asset( match highlighting_query.get_mut(entity) { Ok(Some(mut highlighting)) => highlighting.initial = material.to_owned(), _ => { - commands.entity(entity).insert(InitialHighlight { + commands.entity(entity).try_insert(InitialHighlight { initial: material.to_owned(), }); }