mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Merge pull request #2135 from zed-industries/handle-window-moved-crash
Fix crash when unplugging display containing a zed window
This commit is contained in:
commit
a606058537
1 changed files with 13 additions and 14 deletions
|
@ -910,15 +910,14 @@ impl MutableAppContext {
|
||||||
.map_or(false, |window| window.is_fullscreen)
|
.map_or(false, |window| window.is_fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_bounds(&self, window_id: usize) -> WindowBounds {
|
pub fn window_bounds(&self, window_id: usize) -> Option<WindowBounds> {
|
||||||
self.presenters_and_platform_windows[&window_id].1.bounds()
|
let (_, window) = self.presenters_and_platform_windows.get(&window_id)?;
|
||||||
|
Some(window.bounds())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_display_uuid(&self, window_id: usize) -> Option<Uuid> {
|
pub fn window_display_uuid(&self, window_id: usize) -> Option<Uuid> {
|
||||||
self.presenters_and_platform_windows[&window_id]
|
let (_, window) = self.presenters_and_platform_windows.get(&window_id)?;
|
||||||
.1
|
window.screen().display_uuid()
|
||||||
.screen()
|
|
||||||
.display_uuid()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_view(&mut self, params: RenderParams) -> Result<ElementBox> {
|
pub fn render_view(&mut self, params: RenderParams) -> Result<ElementBox> {
|
||||||
|
@ -2375,8 +2374,10 @@ impl MutableAppContext {
|
||||||
callback(is_fullscreen, this)
|
callback(is_fullscreen, this)
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(uuid) = this.window_display_uuid(window_id) {
|
if let Some((uuid, bounds)) = this
|
||||||
let bounds = this.window_bounds(window_id);
|
.window_display_uuid(window_id)
|
||||||
|
.zip(this.window_bounds(window_id))
|
||||||
|
{
|
||||||
let mut bounds_observations = this.window_bounds_observations.clone();
|
let mut bounds_observations = this.window_bounds_observations.clone();
|
||||||
bounds_observations.emit(window_id, this, |callback, this| {
|
bounds_observations.emit(window_id, this, |callback, this| {
|
||||||
callback(bounds, uuid, this)
|
callback(bounds, uuid, this)
|
||||||
|
@ -2560,8 +2561,10 @@ impl MutableAppContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_window_moved(&mut self, window_id: usize) {
|
fn handle_window_moved(&mut self, window_id: usize) {
|
||||||
if let Some(display) = self.window_display_uuid(window_id) {
|
if let Some((display, bounds)) = self
|
||||||
let bounds = self.window_bounds(window_id);
|
.window_display_uuid(window_id)
|
||||||
|
.zip(self.window_bounds(window_id))
|
||||||
|
{
|
||||||
self.window_bounds_observations
|
self.window_bounds_observations
|
||||||
.clone()
|
.clone()
|
||||||
.emit(window_id, self, move |callback, this| {
|
.emit(window_id, self, move |callback, this| {
|
||||||
|
@ -3733,10 +3736,6 @@ impl<'a, T: View> ViewContext<'a, T> {
|
||||||
self.app.toggle_window_full_screen(self.window_id)
|
self.app.toggle_window_full_screen(self.window_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_bounds(&self) -> WindowBounds {
|
|
||||||
self.app.window_bounds(self.window_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn prompt(
|
pub fn prompt(
|
||||||
&self,
|
&self,
|
||||||
level: PromptLevel,
|
level: PromptLevel,
|
||||||
|
|
Loading…
Reference in a new issue