From 2af3b0df5a7596f1ec988953061b9a09b638c01e Mon Sep 17 00:00:00 2001 From: Nikolay Plekhanov Date: Mon, 14 Oct 2024 00:11:10 +0300 Subject: [PATCH] fix crash on MacOS in notify crate when path is set first time --- editor/src/asset/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/editor/src/asset/mod.rs b/editor/src/asset/mod.rs index e948214e3..baa1d7a04 100644 --- a/editor/src/asset/mod.rs +++ b/editor/src/asset/mod.rs @@ -885,8 +885,14 @@ impl AssetBrowser { message_sender: &MessageSender, ) { if let Some(watcher) = self.watcher.as_mut() { - Log::verify(watcher.unwatch(&self.selected_path)); - Log::verify(watcher.watch(path, RecursiveMode::NonRecursive)); + if self.selected_path.exists() { + Log::verify(watcher.unwatch(&self.selected_path)); + } + if path.exists() { + Log::verify(watcher.watch(path, RecursiveMode::NonRecursive)); + } else { + Log::err(format!("cannot watch non-existing path {:?}", path)); + } } self.selected_path = path.to_path_buf();