1
0
Fork 0
forked from wry/wry

foreign-toplevel: store weak references

This commit is contained in:
Julian Orth 2024-10-08 22:28:44 +02:00
parent 3f9b75e470
commit 9a084a53aa
3 changed files with 31 additions and 14 deletions

View file

@ -3,7 +3,7 @@ use {
client::{Client, ClientError},
leaks::Tracker,
object::{Object, Version},
tree::ToplevelNode,
tree::ToplevelOpt,
wire::{ext_foreign_toplevel_handle_v1::*, ExtForeignToplevelHandleV1Id},
},
std::rc::Rc,
@ -14,16 +14,15 @@ pub struct ExtForeignToplevelHandleV1 {
pub id: ExtForeignToplevelHandleV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub toplevel: Rc<dyn ToplevelNode>,
pub toplevel: ToplevelOpt,
pub version: Version,
}
impl ExtForeignToplevelHandleV1 {
fn detach(&self) {
self.toplevel
.tl_data()
.handles
.remove(&(self.client.id, self.id));
if let Some(tl) = self.toplevel.get() {
tl.tl_data().handles.remove(&(self.client.id, self.id));
}
}
}