diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-10-18 21:24:15 +0800 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-10-22 17:40:50 +0800 |
commit | c754b1deab91b48e6b203dd2c6f1293a124c66af (patch) | |
tree | 438c0e438590e46e10c52ce417df49ae9dc94c7d /libempathy-gtk | |
parent | 4882b051fe63abaa6dc4926442a161f3190df0e6 (diff) | |
download | gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.tar gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.tar.gz gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.tar.bz2 gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.tar.lz gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.tar.xz gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.tar.zst gsoc2013-empathy-c754b1deab91b48e6b203dd2c6f1293a124c66af.zip |
libempathy-gtk: Fix several memory leaks from libgee
libgee’s GeeIterator returns a new reference from most of its methods,
especially gee_iterable_iterator() and gee_iterator_get(). Add corresponding
g_object_unref() calls.
https://bugzilla.gnome.org/show_bug.cgi?id=710453
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-individual-menu.c | 51 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-widget.c | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-model-aggregator.c | 13 |
3 files changed, 48 insertions, 20 deletions
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c index 5dc130983..b7b0abe86 100644 --- a/libempathy-gtk/empathy-individual-menu.c +++ b/libempathy-gtk/empathy-individual-menu.c @@ -129,6 +129,8 @@ individual_menu_add_personas (EmpathyIndividualMenu *self, g_clear_object (&persona); } + g_clear_object (&iter); + /* return early if these entries would add nothing beyond the "quick" items */ if (persona_count <= 1) goto out; @@ -337,11 +339,15 @@ static void call_phone_number (FolksPhoneFieldDetails *details, TpAccount *account) { - DEBUG ("Try to call %s", folks_phone_field_details_get_normalised (details)); + gchar *number; - empathy_call_new_with_streams ( - folks_phone_field_details_get_normalised (details), + number = folks_phone_field_details_get_normalised (details); + DEBUG ("Try to call %s", number); + + empathy_call_new_with_streams (number, account, TRUE, FALSE, empathy_get_current_action_time ()); + + g_free (number); } static void @@ -410,6 +416,7 @@ find_phone_type (FolksPhoneFieldDetails *details) { GeeCollection *types; GeeIterator *iter; + const gchar *retval = NULL; types = folks_abstract_field_details_get_parameter_values ( FOLKS_ABSTRACT_FIELD_DETAILS (details), "type"); @@ -420,17 +427,24 @@ find_phone_type (FolksPhoneFieldDetails *details) iter = gee_iterable_iterator (GEE_ITERABLE (types)); while (gee_iterator_next (iter)) { - const gchar *type = gee_iterator_get (iter); + gchar *type = gee_iterator_get (iter); if (!tp_strdiff (type, "CELL")) - return _("Mobile"); + retval = _("Mobile"); else if (!tp_strdiff (type, "WORK")) - return _("Work"); + retval = _("Work"); else if (!tp_strdiff (type, "HOME")) - return _("HOME"); + retval = _("HOME"); + + g_free (type); + + if (retval != NULL) + break; } - return NULL; + g_object_unref (iter); + + return retval; } static void @@ -451,26 +465,26 @@ add_phone_numbers (EmpathyIndividualMenu *self) { FolksPhoneFieldDetails *details = gee_iterator_get (iter); GtkWidget *item, *image; - gchar *tmp; + gchar *tmp, *number; const gchar *type; type = find_phone_type (details); + number = folks_phone_field_details_get_normalised (details); if (type != NULL) { /* translators: first argument is a phone number like +32123456 and * the second one is something like 'home' or 'work'. */ - tmp = g_strdup_printf (_("Call %s (%s)"), - folks_phone_field_details_get_normalised (details), - type); + tmp = g_strdup_printf (_("Call %s (%s)"), number, type); } else { /* translators: argument is a phone number like +32123456 */ - tmp = g_strdup_printf (_("Call %s"), - folks_phone_field_details_get_normalised (details)); + tmp = g_strdup_printf (_("Call %s"), number); } + g_free (number); + item = gtk_image_menu_item_new_with_mnemonic (tmp); g_free (tmp); @@ -487,6 +501,8 @@ add_phone_numbers (EmpathyIndividualMenu *self) gtk_menu_shell_append (GTK_MENU_SHELL (self), item); gtk_widget_show (item); + + g_object_unref (details); } g_object_unref (iter); @@ -510,17 +526,20 @@ get_contacts_supporting_blocking (FolksIndividual *individual) TpConnection *conn; if (!TPF_IS_PERSONA (persona)) - continue; + goto while_next; contact = tpf_persona_get_contact (persona); if (contact == NULL) - continue; + goto while_next; conn = tp_contact_get_connection (contact); if (tp_proxy_has_interface_by_id (conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) result = g_list_prepend (result, contact); + +while_next: + g_clear_object (&persona); } g_clear_object (&iter); diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c index ca007aaf6..fac2c5a1b 100644 --- a/libempathy-gtk/empathy-individual-widget.c +++ b/libempathy-gtk/empathy-individual-widget.c @@ -1784,6 +1784,7 @@ personas_changed_cb (FolksIndividual *individual, g_clear_object (&persona); } + g_clear_object (&iter); /* * What we display for various conditions: @@ -1849,6 +1850,7 @@ personas_changed_cb (FolksIndividual *individual, add_persona (self, persona); g_clear_object (&persona); } + g_clear_object (&iter); } else if (was_showing_personas && !will_show_personas) { @@ -1860,6 +1862,7 @@ personas_changed_cb (FolksIndividual *individual, remove_persona (self, persona); g_clear_object (&persona); } + g_clear_object (&iter); if (removed != NULL) { @@ -1878,7 +1881,6 @@ personas_changed_cb (FolksIndividual *individual, /* Set up the Individual grid instead */ individual_grid_set_up (self); } - g_clear_object (&iter); /* Hide the last separator and show the others */ children = gtk_container_get_children (GTK_CONTAINER (priv->vbox_individual)); diff --git a/libempathy-gtk/empathy-roster-model-aggregator.c b/libempathy-gtk/empathy-roster-model-aggregator.c index 824e35d9e..26c8f2ae7 100644 --- a/libempathy-gtk/empathy-roster-model-aggregator.c +++ b/libempathy-gtk/empathy-roster-model-aggregator.c @@ -175,7 +175,9 @@ populate_individuals (EmpathyRosterModelAggregator *self) iter = gee_map_map_iterator (individuals); while (gee_map_iterator_next (iter)) { - add_individual (self, gee_map_iterator_get_value (iter)); + FolksIndividual *individual = gee_map_iterator_get_value (iter); + add_individual (self, individual); + g_object_unref (individual); } g_clear_object (&iter); } @@ -195,7 +197,9 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator, while (iter != NULL && gee_iterator_next (iter)) { - add_individual (self, gee_iterator_get (iter)); + FolksIndividual *individual = gee_iterator_get (iter); + add_individual (self, individual); + g_object_unref (individual); } g_clear_object (&iter); } @@ -206,7 +210,9 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator, while (iter != NULL && gee_iterator_next (iter)) { - remove_individual (self, gee_iterator_get (iter)); + FolksIndividual *individual = gee_iterator_get (iter); + remove_individual (self, individual); + g_object_unref (individual); } g_clear_object (&iter); } @@ -405,6 +411,7 @@ empathy_roster_model_aggregator_dup_groups_for_individual ( while (iter != NULL && gee_iterator_next (iter)) { + /* Transfer ownership: */ groups_list = g_list_prepend (groups_list, gee_iterator_get (iter)); } g_clear_object (&iter); |