aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-05-28 17:31:31 +0200
committerfiaxh <git@lightrise.org>2020-06-03 21:50:40 +0200
commit8fe723bccb1dbcc38ec2742195cc77702f7f3f52 (patch)
treec4b8f03db975149555266ed546e48e03f987ad9b /main
parenta9e6a9c3d58002810757f1e3f4fc9c9488b48fc4 (diff)
downloaddino-8fe723bccb1dbcc38ec2742195cc77702f7f3f52.tar.gz
dino-8fe723bccb1dbcc38ec2742195cc77702f7f3f52.zip
Fix cyclic references => let objects be freed
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/conversation_content_view/content_populator.vala7
-rw-r--r--main/src/ui/conversation_content_view/conversation_item_skeleton.vala20
-rw-r--r--main/src/ui/conversation_content_view/file_widget.vala23
3 files changed, 36 insertions, 14 deletions
diff --git a/main/src/ui/conversation_content_view/content_populator.vala b/main/src/ui/conversation_content_view/content_populator.vala
index 2a0f8ac1..48a9e12a 100644
--- a/main/src/ui/conversation_content_view/content_populator.vala
+++ b/main/src/ui/conversation_content_view/content_populator.vala
@@ -86,12 +86,7 @@ public abstract class ContentMetaItem : Plugins.MetaConversationItem {
this.encryption = content_item.encryption;
this.mark = content_item.mark;
- WeakRef weak_item = WeakRef(content_item);
- content_item.notify["mark"].connect(() => {
- ContentItem? ci = weak_item.get() as ContentItem;
- if (ci == null) return;
- this.mark = ci.mark;
- });
+ content_item.bind_property("mark", this, "mark");
this.can_merge = true;
this.requires_avatar = true;
diff --git a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
index b589fe9e..d126f72e 100644
--- a/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_content_view/conversation_item_skeleton.vala
@@ -15,6 +15,7 @@ public class ConversationItemSkeleton : EventBox {
public StreamInteractor stream_interactor;
public Conversation conversation { get; set; }
public Plugins.MetaConversationItem item;
+ public bool item_in_edit_mode { get; set; }
public ContentMetaItem? content_meta_item = null;
public Widget? widget = null;
@@ -30,7 +31,8 @@ public class ConversationItemSkeleton : EventBox {
this.content_meta_item = item as ContentMetaItem;
this.get_style_context().add_class("message-box");
- item.notify["in-edit-mode"].connect(() => {
+ item.bind_property("in-edit-mode", this, "item-in-edit-mode");
+ this.notify["item-in-edit-mode"].connect(() => {
if (item.in_edit_mode) {
this.get_style_context().add_class("edit-mode");
} else {
@@ -112,7 +114,9 @@ public class ItemMetaDataHeader : Box {
private StreamInteractor stream_interactor;
private Conversation conversation;
private Plugins.MetaConversationItem item;
+ public Entities.Message.Marked item_mark { get; set; }
private ArrayList<Plugins.MetaConversationItem> items = new ArrayList<Plugins.MetaConversationItem>();
+ private uint time_update_timeout = 0;
public ItemMetaDataHeader(StreamInteractor stream_interactor, Conversation conversation, Plugins.MetaConversationItem item) {
this.stream_interactor = stream_interactor;
@@ -151,7 +155,8 @@ public class ItemMetaDataHeader : Box {
update_time();
}
- item.notify["mark"].connect_after(update_received_mark);
+ item.bind_property("mark", this, "item-mark");
+ this.notify["item-mark"].connect_after(update_received_mark);
update_received_mark();
}
@@ -172,7 +177,7 @@ public class ItemMetaDataHeader : Box {
private void update_time() {
time_label.label = get_relative_time(item.display_time.to_local()).to_string();
- Timeout.add_seconds((int) get_next_time_change(), () => {
+ time_update_timeout = Timeout.add_seconds((int) get_next_time_change(), () => {
if (this.parent == null) return false;
update_time();
return false;
@@ -276,6 +281,15 @@ public class ItemMetaDataHeader : Box {
return _("Just now");
}
}
+
+ public override void dispose() {
+ base.dispose();
+
+ if (time_update_timeout != 0) {
+ Source.remove(time_update_timeout);
+ time_update_timeout = 0;
+ }
+ }
}
}
diff --git a/main/src/ui/conversation_content_view/file_widget.vala b/main/src/ui/conversation_content_view/file_widget.vala
index 3819e5bc..a965db47 100644
--- a/main/src/ui/conversation_content_view/file_widget.vala
+++ b/main/src/ui/conversation_content_view/file_widget.vala
@@ -37,6 +37,8 @@ public class FileWidget : SizeRequestBox {
private StreamInteractor stream_interactor;
private FileTransfer file_transfer;
+ public FileTransfer.State file_transfer_state { get; set; }
+ public string file_transfer_mime_type { get; set; }
private State? state = null;
private FileDefaultWidgetController default_widget_controller;
@@ -58,8 +60,11 @@ public class FileWidget : SizeRequestBox {
}
});
- file_transfer.notify["state"].connect(update_widget);
- file_transfer.notify["mime-type"].connect(update_widget);
+ file_transfer.bind_property("state", this, "file-transfer-state");
+ file_transfer.bind_property("mime-type", this, "file-transfer-mime-type");
+
+ this.notify["file-transfer-state"].connect(update_widget);
+ this.notify["file-transfer-mime-type"].connect(update_widget);
}
private async void update_widget() {
@@ -115,6 +120,10 @@ public class FileDefaultWidgetController : Object {
private FileDefaultWidget widget;
private FileTransfer? file_transfer;
+ public string file_transfer_path { get; set; }
+ public string file_transfer_state { get; set; }
+ public string file_transfer_mime_type { get; set; }
+
private StreamInteractor? stream_interactor;
private string file_uri;
private FileTransfer.State state;
@@ -130,9 +139,13 @@ public class FileDefaultWidgetController : Object {
widget.name_label.label = file_transfer.file_name;
- file_transfer.notify["path"].connect(update_file_info);
- file_transfer.notify["state"].connect(update_file_info);
- file_transfer.notify["mime-type"].connect(update_file_info);
+ file_transfer.bind_property("path", this, "file-transfer-path");
+ file_transfer.bind_property("state", this, "file-transfer-state");
+ file_transfer.bind_property("mime-type", this, "file-transfer-mime-type");
+
+ this.notify["file-transfer-path"].connect(update_file_info);
+ this.notify["file-transfer-state"].connect(update_file_info);
+ this.notify["file-transfer-mime-type"].connect(update_file_info);
update_file_info();
}