Fix memory leak

This commit is contained in:
fiaxh 2017-11-22 21:09:39 +01:00
parent 9165c4db27
commit 64774241e5
10 changed files with 22 additions and 18 deletions

View file

@ -250,7 +250,6 @@
<object class="GtkLabel" id="notification_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">This is an app-notification. Click the button to dismiss</property>
</object>
<packing>
<property name="expand">False</property>

View file

@ -59,10 +59,6 @@ msgstr ""
msgid "Password"
msgstr ""
#: ../data/add_conversation/conference_details_fragment.ui:253
msgid "This is an app-notification. Click the button to dismiss"
msgstr ""
#: ../data/conversation_selector/view.ui:14
msgid "Search"
msgstr ""

View file

@ -47,7 +47,7 @@ public class SelectJidFragment : Gtk.Box {
public void set_filter(string str) {
if (entry.text != str) entry.text = str;
foreach (AddListRow row in added_rows) filterable_list.remove(row);
foreach (AddListRow row in added_rows) row.destroy();
added_rows.clear();
string[] ? values = str == "" ? null : str.split(" ");

View file

@ -46,7 +46,8 @@ public class ConversationItemSkeleton : Grid {
}
public void remove_meta_item(Plugins.MetaConversationItem item) {
box.remove(item_widgets[item]);
item_widgets[item].destroy();
item_widgets.unset(item);
items.remove(item);
}

View file

@ -84,9 +84,10 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
if (skeleton.items.size > 1) {
skeleton.remove_meta_item(item);
} else {
main.remove(widgets[item]);
widgets[item].destroy();
widgets.unset(item);
item_skeletons.remove(item_item_skeletons[item]);
skeleton.destroy();
item_skeletons.remove(skeleton);
item_item_skeletons.unset(item);
}
meta_items.remove(item);
@ -233,7 +234,8 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
meta_after_items.clear();
item_skeletons.clear();
item_item_skeletons.clear();
main.@foreach((widget) => { main.remove(widget); });
widgets.clear();
main.@foreach((widget) => { widget.destroy(); });
}
}

View file

@ -55,8 +55,13 @@ public class MessagePopulator : Object {
if (meta_item == null) return;
meta_item.mark = message.marked;
WeakRef weak_meta_item = WeakRef(meta_item);
WeakRef weak_message = WeakRef(message);
message.notify["marked"].connect(() => {
meta_item.mark = message.marked;
Plugins.MetaConversationItem? mi = weak_meta_item.get() as Plugins.MetaConversationItem;
Message? m = weak_message.get() as Message;
if (mi == null || m == null) return;
mi.mark = m.marked;
});
item_collection.insert_item(meta_item);
}

View file

@ -29,9 +29,9 @@ class OccupantsWidget : MenuButton, Plugins.ConversationTitlebarWidget {
private Conversation? conversation;
private StreamInteractor stream_interactor;
private Window window;
private OccupantMenu.View menu = null;
public OccupantsWidget(StreamInteractor stream_interactor, Window window) {
image = new Image.from_icon_name("system-users-symbolic", IconSize.MENU);
this.stream_interactor = stream_interactor;
@ -44,8 +44,10 @@ class OccupantsWidget : MenuButton, Plugins.ConversationTitlebarWidget {
visible = conversation.type_ == Conversation.Type.GROUPCHAT;
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
OccupantMenu.View menu = new OccupantMenu.View(stream_interactor, window, conversation);
set_popover(menu);
OccupantMenu.View new_menu = new OccupantMenu.View(stream_interactor, window, conversation);
set_popover(new_menu);
if (menu != null) menu.destroy();
menu = new_menu;
}
}
}

View file

@ -128,8 +128,7 @@ public class Dialog : Gtk.Dialog {
ok_button.label = _("Remove");
ok_button.get_style_context().add_class("destructive-action");
if (msg.run() == Gtk.ResponseType.OK) {
account_list.remove(account_item);
account_list.queue_draw();
account_item.destroy();
if (account_item.account.enabled) account_disabled(account_item.account);
account_item.account.remove();
if (account_list.get_row_at_index(0) != null) {

View file

@ -94,7 +94,7 @@ public class View : Popover {
kick_button.clicked.connect(kick_button_clicked);
}
if (jid_menu != null) stack.remove(jid_menu);
if (jid_menu != null) jid_menu.destroy();
stack.add_named(outer_box, "menu");
stack.visible_child_name = "menu";
jid_menu = outer_box;

View file

@ -29,7 +29,7 @@ public class AccountSettingsDialog : Gtk.Dialog {
foreach (Row row in plugin.db.identity_meta.with_address(account.bare_jid.to_string())) {
if (row[plugin.db.identity_meta.device_id] == own_id) continue;
if (i == 0) {
other_list.foreach((widget) => { other_list.remove(widget); });
other_list.foreach((widget) => { widget.destroy(); });
}
string? other_b64 = row[plugin.db.identity_meta.identity_key_public_base64];
Label lbl = new Label(other_b64 != null ? fingerprint_markup(fingerprint_from_base64(other_b64)) : _("Unknown device (0x%xd)").printf(row[plugin.db.identity_meta.device_id])) { use_markup = true, visible = true, margin = 8, selectable=true };