foreign-toplevel: store weak references
This commit is contained in:
parent
3f9b75e470
commit
9a084a53aa
3 changed files with 31 additions and 14 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue