Fix window double borrows (#23739)
Fix bugs caused by the window context PR, where the window could be on the stack and is then requested from the App. This PR also adds derive macros for `AppContext` and `VisualContext` so that it's easy to define further contexts in API code, such as `editor::BlockContext`. Release Notes: - N/A
This commit is contained in:
parent
29bfb56739
commit
a7c549b85b
24 changed files with 465 additions and 297 deletions
|
@ -1236,15 +1236,9 @@ impl App {
|
|||
T: 'static,
|
||||
{
|
||||
let window_handle = window.handle;
|
||||
let (subscription, activate) = self.release_listeners.insert(
|
||||
handle.entity_id(),
|
||||
Box::new(move |entity, cx| {
|
||||
let entity = entity.downcast_mut().expect("invalid entity type");
|
||||
let _ = window_handle.update(cx, |_, window, cx| on_release(entity, window, cx));
|
||||
}),
|
||||
);
|
||||
activate();
|
||||
subscription
|
||||
self.observe_release(&handle, move |entity, cx| {
|
||||
let _ = window_handle.update(cx, |_, window, cx| on_release(entity, window, cx));
|
||||
})
|
||||
}
|
||||
|
||||
/// Register a callback to be invoked when a keystroke is received by the application
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue