aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/widgets
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2023-02-27 23:38:31 +0100
committerfiaxh <git@lightrise.org>2023-02-27 23:38:31 +0100
commitfb799e3ba8313ff2da53d9d5c34f8421f164cbf1 (patch)
tree2de44bcf7a01917610d9ad96396da3df5a314ae9 /main/src/ui/widgets
parentc526848098ff187615f0be0b531c9b45644d0e03 (diff)
downloaddino-fb799e3ba8313ff2da53d9d5c34f8421f164cbf1.tar.gz
dino-fb799e3ba8313ff2da53d9d5c34f8421f164cbf1.zip
Fix some memory leaks
Diffstat (limited to 'main/src/ui/widgets')
-rw-r--r--main/src/ui/widgets/date_separator.vala10
1 files changed, 8 insertions, 2 deletions
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;
});
}