Fix double read panic in nav history (#22754)

This one seems to be triggered when the assistant's
`View<ContextEditor>` is leased during the call into
`NavHistory::for_each_entry`, which then tries to read it again through
the `ItemHandle` interface. Fix it by skipping entries that can't be
read in the history iteration.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-01-08 18:05:34 -05:00 committed by GitHub
parent ef583e6b5a
commit 1d8bd151b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 4 deletions

View file

@ -320,6 +320,10 @@ pub trait Item: FocusableView + EventEmitter<Self::Event> {
fn preserve_preview(&self, _cx: &AppContext) -> bool {
false
}
fn include_in_nav_history() -> bool {
true
}
}
pub trait SerializableItem: Item {
@ -464,6 +468,7 @@ pub trait ItemHandle: 'static + Send {
fn downgrade_item(&self) -> Box<dyn WeakItemHandle>;
fn workspace_settings<'a>(&self, cx: &'a AppContext) -> &'a WorkspaceSettings;
fn preserve_preview(&self, cx: &AppContext) -> bool;
fn include_in_nav_history(&self) -> bool;
}
pub trait WeakItemHandle: Send + Sync {
@ -877,6 +882,10 @@ impl<T: Item> ItemHandle for View<T> {
fn preserve_preview(&self, cx: &AppContext) -> bool {
self.read(cx).preserve_preview(cx)
}
fn include_in_nav_history(&self) -> bool {
T::include_in_nav_history()
}
}
impl From<Box<dyn ItemHandle>> for AnyView {