From fb799e3ba8313ff2da53d9d5c34f8421f164cbf1 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 27 Feb 2023 23:38:31 +0100 Subject: Fix some memory leaks --- main/src/ui/widgets/date_separator.vala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'main/src/ui/widgets') diff --git a/main/src/ui/widgets/date_separator.vala b/main/src/ui/widgets/date_separator.vala index 95729bce..b5d84a5b 100644 --- a/main/src/ui/widgets/date_separator.vala +++ b/main/src/ui/widgets/date_separator.vala @@ -40,8 +40,14 @@ public class Dino.Ui.ViewModel.CompatDateSeparatorModel : DateSeparatorModel { private void update_time_label() { date_label = get_relative_time(date); - time_update_timeout = Timeout.add_seconds((int) get_next_time_change(), () => { - if (time_update_timeout != 0) update_time_label(); + time_update_timeout = set_update_time_label_timeout((int) get_next_time_change(), this); + } + + private static uint set_update_time_label_timeout(int interval, CompatDateSeparatorModel model_) { + WeakRef model_weak = WeakRef(model_); + return Timeout.add_seconds(interval, () => { + CompatDateSeparatorModel? model = (CompatDateSeparatorModel) model_weak.get(); + if (model != null && model.time_update_timeout != 0) model.update_time_label(); return false; }); } -- cgit v1.2.3-70-g09d2