prevent crash when trying to select node by invalid handle
@@ -1572,11 +1572,18 @@ impl Editor {
fn select_object(&mut self, type_id: TypeId, handle: ErasedHandle) {
if let Some(scene) = self.scene.as_ref() {
let new_selection = if type_id == TypeId::of::<Node>() {
+ if self.engine.scenes[scene.scene]
+ .graph
+ .is_valid_handle(handle.into())
+ {
Some(Selection::Graph(GraphSelection::single_or_empty(
handle.into(),
)))
} else {
None
+ }
+ } else {
+ None
};
if let Some(new_selection) = new_selection {
