messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit 5dc6434881b15973742d403cd7ca0cd11f2ade28
parent d1f4844fba95d62806931cdd5930b692379e793b
Author: Jacki <jacki@thejackimonster.de>
Date:   Sat, 10 Feb 2024 04:15:49 +0100

Cleanup allocated memory of lists and more

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Msrc/application.c | 8+++++++-
Msrc/event.c | 6++++++
Msrc/ui/accounts.c | 10+++++++---
Msrc/ui/chat.c | 23+++++++++++++++++------
Msrc/ui/messenger.c | 6++++--
Msrc/ui/new_group.c | 14+++++++++-----
Msrc/ui/picker.c | 2++
7 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/src/application.c b/src/application.c @@ -604,14 +604,19 @@ application_exit(MESSENGER_Application *app, write(app->chat.pipe[1], &signal, sizeof(signal)); if (app->portal) - g_free(app->portal); + g_object_unref(app->portal); app->portal = NULL; + if (app->pw.registry) + pw_proxy_destroy((struct pw_proxy*) app->pw.registry); + if (app->pw.core) { pw_map_for_each(&(app->pw.globals), destroy_global, NULL); pw_map_clear(&(app->pw.globals)); + + pw_core_disconnect(app->pw.core); } if (app->pw.context) @@ -623,6 +628,7 @@ application_exit(MESSENGER_Application *app, pw_main_loop_destroy(app->pw.main_loop); } + gst_deinit(); pw_deinit(); } diff --git a/src/event.c b/src/event.c @@ -296,6 +296,12 @@ _clear_chat_entry(GtkWidget *widget, app->quarks.ui ); + g_object_set_qdata( + G_OBJECT(entry->chat->send_text_view), + app->quarks.data, + NULL + ); + ui_chat_entry_dispose(entry, app); } diff --git a/src/ui/accounts.c b/src/ui/accounts.c @@ -196,9 +196,10 @@ ui_accounts_dialog_refresh(MESSENGER_Application *app, GTK_CONTAINER(handle->accounts_listbox) ); - while (list) + GList *item = list; + while (item) { - GtkListBoxRow *row = GTK_LIST_BOX_ROW(list->data); + GtkListBoxRow *row = GTK_LIST_BOX_ROW(item->data); if ((!row) || (!gtk_list_box_row_get_selectable(row))) goto skip_row; @@ -209,9 +210,12 @@ ui_accounts_dialog_refresh(MESSENGER_Application *app, ); skip_row: - list = list->next; + item = item->next; } + if (list) + g_list_free(list); + GNUNET_CHAT_iterate_accounts( app->chat.messenger.handle, _iterate_accounts, diff --git a/src/ui/chat.c b/src/ui/chat.c @@ -160,6 +160,7 @@ handle_back_button_click(UNUSED GtkButton *button, if (children) { hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->data)); + g_list_free(children); } } @@ -299,12 +300,16 @@ handle_chat_messages_selected_rows_changed(GtkListBox *listbox, GList *selected = gtk_list_box_get_selected_rows(listbox); uint32_t count = 0; - while (selected) + GList *item = selected; + while (item) { count++; - selected = selected->next; + item = item->next; } + if (selected) + g_list_free(selected); + GString *counter = g_string_new(""); g_string_append_printf(counter, "%u", count); gtk_label_set_text(handle->selection_count_label, counter->str); @@ -384,6 +389,9 @@ handle_chat_selection_delete_button_click(UNUSED GtkButton *button, gtk_widget_show(GTK_WIDGET(app->ui.delete_messages.dialog)); } + + if (selected) + g_list_free(selected); } static void @@ -1584,9 +1592,10 @@ ui_chat_update(UI_CHAT_Handle *handle, GTK_CONTAINER(handle->chat_contacts_listbox) ); - while ((children) && (children->next)) { - GtkWidget *widget = GTK_WIDGET(children->data); - children = children->next; + GList *item = children; + while ((item) && (item->next)) { + GtkWidget *widget = GTK_WIDGET(item->data); + item = item->next; gtk_container_remove( GTK_CONTAINER(handle->chat_contacts_listbox), @@ -1594,6 +1603,9 @@ ui_chat_update(UI_CHAT_Handle *handle, ); } + if (children) + g_list_free(children); + if (group) { struct IterateChatGroupClosure closure; @@ -1658,7 +1670,6 @@ ui_chat_update(UI_CHAT_Handle *handle, return; GList *list = handle->messages; - while (list) { ui_message_refresh((UI_MESSAGE_Handle*) list->data); diff --git a/src/ui/messenger.c b/src/ui/messenger.c @@ -232,9 +232,11 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, GList *children = gtk_container_get_children(GTK_CONTAINER(leaflet)); - if ((children) && (children->next)) { + if ((children) && (children->next)) hdy_leaflet_set_visible_child(leaflet, GTK_WIDGET(children->next->data)); - } + + if (children) + g_list_free(children); gtk_stack_set_visible_child(stack, entry->chat->chat_box); } diff --git a/src/ui/new_group.c b/src/ui/new_group.c @@ -44,21 +44,25 @@ _open_new_group(GtkEntry *entry, GList *selected = gtk_list_box_get_selected_rows(listbox); - while (selected) + GList *item = selected; + while (item) { - if (selected->data) + if (item->data) { - GtkListBoxRow *row = GTK_LIST_BOX_ROW(selected->data); + GtkListBoxRow *row = GTK_LIST_BOX_ROW(item->data); struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( - g_object_get_qdata(G_OBJECT(row), app->quarks.data) + g_object_get_qdata(G_OBJECT(row), app->quarks.data) ); GNUNET_CHAT_group_invite_contact(group, contact); } - selected = selected->next; + item = item->next; } + + if (selected) + g_list_free(selected); } static void diff --git a/src/ui/picker.c b/src/ui/picker.c @@ -97,6 +97,7 @@ _filter_emoji_buttons(GtkWidget* widget, return; GtkButton *emoji_button = GTK_BUTTON(list->data); + g_list_free(list); list = gtk_container_get_children(GTK_CONTAINER(emoji_button)); @@ -104,6 +105,7 @@ _filter_emoji_buttons(GtkWidget* widget, return; GtkLabel *label = GTK_LABEL(list->data); + g_list_free(list); const gchar *text = gtk_label_get_text(label);