Avoid accessing node global during Node's destructor.

This commit is contained in:
Josh Matthews 2019-12-19 18:15:30 -05:00
parent 3e95efdea6
commit 1449bac0e1
3 changed files with 42 additions and 13 deletions

View file

@ -821,6 +821,23 @@ impl ScriptThreadFactory for ScriptThread {
}
impl ScriptThread {
pub(crate) fn get_any_layout_chan() -> Option<Sender<Msg>> {
SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = match root.get() {
Some(s) => unsafe { &*s },
None => return None,
};
script_thread
.documents
.borrow()
.map
.values()
.next()
.map(|d| d.window().layout_chan())
.cloned()
})
}
pub fn runtime_handle() -> ParentRuntime {
SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() };