Skip to content

Commit

Permalink
Merge pull request #687 from kkolyan/path_crash
Browse files Browse the repository at this point in the history
fix crash on MacOS in `notify` crate when path is set first time with "Default::default"
  • Loading branch information
mrDIMAS authored Oct 13, 2024
2 parents 8e3445c + 9d567af commit f0c6568
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions editor/src/asset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,15 @@ 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));
// notify 6.1.1 crashes otherwise
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();
Expand Down

0 comments on commit f0c6568

Please sign in to comment.