diff options
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 38 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 60 |
2 files changed, 53 insertions, 45 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 1a771fe98b..27c0f5b5c2 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -433,6 +433,7 @@ style_makes_sense (const EContactName *name, else return FALSE; } + return FALSE; case 3: if (company && *company) return TRUE; @@ -1125,7 +1126,7 @@ extract_email (EContactEditor *editor) { GList *attr_list = NULL; GList *old_attr_list; - GList *l, *l_next; + GList *ll; gint i; for (i = 1; i <= EMAIL_SLOTS; i++) { @@ -1157,14 +1158,12 @@ extract_email (EContactEditor *editor) /* Splice in the old attributes, minus the EMAIL_SLOTS first */ old_attr_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL); - for (l = old_attr_list, i = 1; l && i <= EMAIL_SLOTS; l = l_next, i++) { - l_next = g_list_next (l); - - e_vcard_attribute_free (l->data); - l = g_list_delete_link (l, l); + for (ll = old_attr_list, i = 1; ll && i <= EMAIL_SLOTS; i++) { + e_vcard_attribute_free (ll->data); + ll = g_list_delete_link (ll, ll); } - old_attr_list = l; + old_attr_list = ll; attr_list = g_list_concat (attr_list, old_attr_list); e_contact_set_attributes (editor->contact, E_CONTACT_EMAIL, attr_list); @@ -1468,7 +1467,7 @@ extract_phone (EContactEditor *editor) { GList *attr_list = NULL; GList *old_attr_list; - GList *l, *l_next; + GList *ll; gint i; for (i = 1; i <= PHONE_SLOTS; i++) { @@ -1509,14 +1508,12 @@ extract_phone (EContactEditor *editor) /* Splice in the old attributes, minus the PHONE_SLOTS first */ old_attr_list = get_attributes_named (E_VCARD (editor->contact), "TEL"); - for (l = old_attr_list, i = 1; l && i <= PHONE_SLOTS; l = l_next, i++) { - l_next = g_list_next (l); - - e_vcard_attribute_free (l->data); - l = g_list_delete_link (l, l); + for (ll = old_attr_list, i = 1; ll && i <= PHONE_SLOTS; i++) { + e_vcard_attribute_free (ll->data); + ll = g_list_delete_link (ll, ll); } - old_attr_list = l; + old_attr_list = ll; attr_list = g_list_concat (attr_list, old_attr_list); set_attributes_named (E_VCARD (editor->contact), "TEL", attr_list); @@ -1913,7 +1910,7 @@ extract_im (EContactEditor *editor) for (i = 0; i < G_N_ELEMENTS (im_service); i++) { GList *old_service_attr_list; gint filled_in_slots; - GList *l, *l_next; + GList *ll; gint j; /* Splice in the old attributes, minus the filled_in_slots first */ @@ -1925,15 +1922,14 @@ extract_im (EContactEditor *editor) g_list_length (old_service_attr_list)); remaining_slots -= filled_in_slots; - for (l = old_service_attr_list, j = 0; - l && j < filled_in_slots; l = l_next, j++) { - l_next = g_list_next (l); + for (ll = old_service_attr_list, j = 0; + ll && j < filled_in_slots; j++) { - e_vcard_attribute_free (l->data); - l = g_list_delete_link (l, l); + e_vcard_attribute_free (ll->data); + ll = g_list_delete_link (ll, ll); } - old_service_attr_list = l; + old_service_attr_list = ll; service_attr_list[i] = g_list_concat ( service_attr_list[i], old_service_attr_list); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 4bcaa9bbfb..8a5dbf087e 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -502,9 +502,9 @@ contact_list_editor_selection_changed_cb (GtkTreeSelection *selection, gtk_widget_set_sensitive (WIDGET (UP_BUTTON), FALSE); } - gtk_tree_model_get_iter (model, &iter, g_list_last (selected)->data); /* Item below last selected exists => enable Down/Bottom buttons */ - if (gtk_tree_model_iter_next (model, &iter)) { + if (gtk_tree_model_get_iter (model, &iter, g_list_last (selected)->data) && + gtk_tree_model_iter_next (model, &iter)) { gtk_widget_set_sensitive (WIDGET (DOWN_BUTTON), TRUE); gtk_widget_set_sensitive (WIDGET (BOTTOM_BUTTON), TRUE); } else { @@ -888,9 +888,11 @@ contact_list_editor_remove_button_clicked_cb (GtkWidget *widget) path = gtk_tree_row_reference_get_path (reference); valid = gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); - g_assert (valid); - - e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (model), &iter); + if (valid) { + e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (model), &iter); + } else { + g_warn_if_reached (); + } gtk_tree_row_reference_free (reference); } @@ -967,7 +969,9 @@ contact_list_editor_select_button_clicked_cb (GtkWidget *widget) for (iter = list; iter != NULL; iter = iter->next) { EDestination *destination = iter->data; - contact_list_editor_add_destination (widget, destination); + if (!contact_list_editor_add_destination (widget, destination)) + g_warning ("%s: Failed to add destination", G_STRFUNC); + e_destination_store_remove_destination (store, destination); } @@ -1066,9 +1070,9 @@ contact_list_editor_top_button_clicked_cb (GtkButton *button) for (l = references; l; l = l->next) { path = gtk_tree_row_reference_get_path (l->data); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_store_move_after ( - GTK_TREE_STORE (model), &iter, NULL); + if (gtk_tree_model_get_iter (model, &iter, path)) + gtk_tree_store_move_after ( + GTK_TREE_STORE (model), &iter, NULL); gtk_tree_path_free (path); } @@ -1105,16 +1109,19 @@ contact_list_editor_up_button_clicked_cb (GtkButton *button) /* Get iter of item above the first selected item */ path = gtk_tree_path_copy (selected->data); gtk_tree_path_prev (path); - gtk_tree_model_get_iter (model, &iter, path); + if (!gtk_tree_model_get_iter (model, &iter, path)) { + gtk_tree_path_free (path); + g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free); + return; + } gtk_tree_path_free (path); /* Get iter of the last selected item */ - gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data); + if (gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data)) { + gtk_tree_store_move_after (GTK_TREE_STORE (model), &iter, &iter2); + } - gtk_tree_store_move_after (GTK_TREE_STORE (model), &iter, &iter2); - - g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL); - g_list_free (selected); + g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free); contact_list_editor_selection_changed_cb (selection, editor); } @@ -1141,16 +1148,21 @@ contact_list_editor_down_button_clicked_cb (GtkButton *button) selected = gtk_tree_selection_get_selected_rows (selection, &model); /* Iter of the first selected item */ - gtk_tree_model_get_iter (model, &iter, selected->data); + if (!gtk_tree_model_get_iter (model, &iter, selected->data)) { + g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free); + return; + } /* Iter of item below the last selected item */ - gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data); - gtk_tree_model_iter_next (model, &iter2); + if (!gtk_tree_model_get_iter (model, &iter2, g_list_last (selected)->data) || + !gtk_tree_model_iter_next (model, &iter2)) { + g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free); + return; + } gtk_tree_store_move_before (GTK_TREE_STORE (model), &iter2, &iter); - g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL); - g_list_free (selected); + g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free); contact_list_editor_selection_changed_cb (selection, editor); } @@ -1828,10 +1840,10 @@ save_contact_list (GtkTreeModel *model, g_free (uid); /* Set new_iter to first child of iter */ - gtk_tree_model_iter_children (model, &new_iter, iter); - - /* Go recursive */ - save_contact_list (model, &new_iter, attrs, parent_id); + if (gtk_tree_model_iter_children (model, &new_iter, iter)) { + /* Go recursive */ + save_contact_list (model, &new_iter, attrs, parent_id); + } } else { attr = e_vcard_attribute_new (NULL, EVC_EMAIL); e_destination_export_to_vcard_attribute (dest, attr); |