From 336b9a126eeb9b6898b29590919f0ca21e590383 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Mon, 13 Aug 2018 08:42:05 +0300 Subject: [PATCH] InAppNotif: Fix ref cycles --- podcasts-gtk/src/widgets/appnotif.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/podcasts-gtk/src/widgets/appnotif.rs b/podcasts-gtk/src/widgets/appnotif.rs index cf439ff..e6abd0a 100644 --- a/podcasts-gtk/src/widgets/appnotif.rs +++ b/podcasts-gtk/src/widgets/appnotif.rs @@ -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); });