InAppNotif: Fix ref cycles

This commit is contained in:
Jordan Petridis 2018-08-13 08:42:05 +03:00
parent 01efbf5c79
commit 336b9a126e
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -47,8 +47,13 @@ impl InAppNotification {
let notif = InAppNotification::default();
notif.text.set_text(&text);
let revealer = notif.revealer.clone();
let revealer_weak = notif.revealer.downgrade();
let id = timeout_add_seconds(6, move || {
let revealer = match revealer_weak.upgrade() {
Some(r) => r,
None => return,
};
revealer.set_reveal_child(false);
callback()
});
@ -75,8 +80,13 @@ impl InAppNotification {
});
// Hide the revealer when the close button is clicked
let revealer = notif.revealer.clone();
let revealer_weak = notif.revealer.downgrade();
notif.close.connect_clicked(move |_| {
let revealer = match revealer_weak.upgrade() {
Some(r) => r,
None => return,
};
revealer.set_reveal_child(false);
});