wayland: avoid noisy panic-within-panic on shutdown
Ensure that we eagerly clear the window map to avoid drop-during-global-dtor related panic which confuses the root cause of wayland protocol errors.
This commit is contained in:
1 parent
d6063e180a
commit
1e61d1ea8b
3 files changed
+24
-11
No files matched your search
@@ -277,6 +277,10 @@ thread_local! {
|
||||
static FRONT_END: RefCell<Option<Rc<GuiFrontEnd>>> = RefCell::new(None);
|
||||
}
|
||||
|
||||
pub fn try_front_end() -> Option<Rc<GuiFrontEnd>> {
|
||||
FRONT_END.with(|f| f.borrow().as_ref().map(Rc::clone))
|
||||
}
|
||||
|
||||
pub fn front_end() -> Rc<GuiFrontEnd> {
|
||||
FRONT_END
|
||||
.with(|f| f.borrow().as_ref().map(Rc::clone))
|
||||
|
||||
@@ -3,7 +3,7 @@ use super::renderstate::*;
|
||||
use super::utilsprites::RenderMetrics;
|
||||
use crate::cache::LruCache;
|
||||
use crate::colorease::ColorEase;
|
||||
use crate::frontend::front_end;
|
||||
use crate::frontend::{front_end, try_front_end};
|
||||
use crate::glium::texture::SrgbTexture2d;
|
||||
use crate::inputmap::InputMap;
|
||||
use crate::overlay::{
|
||||
@@ -2892,7 +2892,9 @@ impl TermWindow {
|
||||
impl Drop for TermWindow {
|
||||
fn drop(&mut self) {
|
||||
if let Some(window) = self.window.take() {
|
||||
front_end().forget_known_window(&window);
|
||||
if let Some(fe) = try_front_end() {
|
||||
fe.forget_known_window(&window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,14 +264,8 @@ impl WaylandConnection {
|
||||
|
||||
future
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectionOps for WaylandConnection {
|
||||
fn terminate_message_loop(&self) {
|
||||
*self.should_terminate.borrow_mut() = true;
|
||||
}
|
||||
|
||||
fn run_message_loop(&self) -> anyhow::Result<()> {
|
||||
fn run_message_loop_impl(&self) -> anyhow::Result<()> {
|
||||
const TOK_WL: usize = 0xffff_fffc;
|
||||
const TOK_SPAWN: usize = 0xffff_fffd;
|
||||
let tok_wl = Token(TOK_WL);
|
||||
@@ -343,8 +337,21 @@ impl ConnectionOps for WaylandConnection {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.windows.borrow_mut().clear();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ConnectionOps for WaylandConnection {
|
||||
fn terminate_message_loop(&self) {
|
||||
*self.should_terminate.borrow_mut() = true;
|
||||
}
|
||||
|
||||
fn run_message_loop(&self) -> anyhow::Result<()> {
|
||||
let res = self.run_message_loop_impl();
|
||||
// Ensure that we drop these eagerly, to avoid
|
||||
// noisy errors wrt. global destructors unwinding
|
||||
// in unexpected places
|
||||
self.windows.borrow_mut().clear();
|
||||
res
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user