Move debug_elements
to AsyncAppContext
Previously, `debug_elements` was available on `WindowContext`. If that method was called while having a borrow out to a view, it would panic because the view would already have been borrowed. By moving it to an `AsyncAppContext` we ensure the method can't be called while a view is being used.
This commit is contained in:
parent
4c1cba6def
commit
794446bf8b
4 changed files with 23 additions and 20 deletions
|
@ -43,6 +43,7 @@ use window_input_handler::WindowInputHandler;
|
|||
use crate::{
|
||||
elements::{AnyElement, AnyRootElement, RootElement},
|
||||
executor::{self, Task},
|
||||
json,
|
||||
keymap_matcher::{self, Binding, KeymapContext, KeymapMatcher, Keystroke, MatchResult},
|
||||
platform::{
|
||||
self, FontSystem, KeyDownEvent, KeyUpEvent, ModifiersChangedEvent, MouseButton,
|
||||
|
@ -309,6 +310,14 @@ impl AsyncAppContext {
|
|||
self.0.borrow_mut().update_window(window_id, callback)
|
||||
}
|
||||
|
||||
pub fn debug_elements(&self, window_id: usize) -> Option<json::Value> {
|
||||
self.0.borrow().read_window(window_id, |cx| {
|
||||
let root_view = cx.window.root_view();
|
||||
let root_element = cx.window.rendered_views.get(&root_view.id())?;
|
||||
root_element.debug(cx).log_err()
|
||||
})?
|
||||
}
|
||||
|
||||
pub fn dispatch_action(
|
||||
&mut self,
|
||||
window_id: usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue