From 5b0b0ef1e0927bab72cdd9a874e17aa514c71609 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 11 Sep 2000 20:27:38 +0000 Subject: Fixed a crash error. 2000-09-11 Christopher James Lahey * contact-editor/e-contact-editor.c: Fixed a crash error. svn path=/trunk/; revision=5342 --- addressbook/contact-editor/e-contact-editor.c | 39 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'addressbook/contact-editor') diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c index 16c14bf585..c259ea9587 100644 --- a/addressbook/contact-editor/e-contact-editor.c +++ b/addressbook/contact-editor/e-contact-editor.c @@ -261,7 +261,7 @@ style_makes_sense(const ECardName *name, char *company, int style) return FALSE; case 3: /* Fall Through */ case 4: - if (company && *company && ((name->given && *name->given) || (name->family && *name->family))) + if (company && *company && name && ((name->given && *name->given) || (name->family && *name->family))) return TRUE; else return FALSE; @@ -279,19 +279,23 @@ name_to_style(const ECardName *name, char *company, int style) switch (style) { case 0: stringptr = strings; - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; + if (name) { + if (name->family && *name->family) + *(stringptr++) = name->family; + if (name->given && *name->given) + *(stringptr++) = name->given; + } *stringptr = NULL; string = g_strjoinv(", ", strings); break; case 1: stringptr = strings; - if (name->given && *name->given) - *(stringptr++) = name->given; - if (name->family && *name->family) - *(stringptr++) = name->family; + if (name) { + if (name->given && *name->given) + *(stringptr++) = name->given; + if (name->family && *name->family) + *(stringptr++) = name->family; + } *stringptr = NULL; string = g_strjoinv(" ", strings); break; @@ -301,10 +305,12 @@ name_to_style(const ECardName *name, char *company, int style) case 3: /* Fall Through */ case 4: stringptr = strings; - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; + if (name) { + if (name->family && *name->family) + *(stringptr++) = name->family; + if (name->given && *name->given) + *(stringptr++) = name->given; + } *stringptr = NULL; substring = g_strjoinv(", ", strings); if (!(company && *company)) @@ -331,8 +337,6 @@ file_as_get_style (EContactEditor *editor) int i; int style; - if (!name) return 0; - filestring = e_utf8_gtk_entry_get_text(file_as); style = -1; @@ -1015,7 +1019,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor) e_contact_editor->email_list = NULL; e_contact_editor->phone_list = NULL; e_contact_editor->address_list = NULL; - e_contact_editor->name = NULL; + e_contact_editor->name = e_card_name_new(); e_contact_editor->company = g_strdup(""); e_contact_editor->email_choice = 0; @@ -1119,6 +1123,9 @@ e_contact_editor_destroy (GtkObject *object) { if (e_contact_editor->simple) gtk_object_unref(GTK_OBJECT(e_contact_editor->simple)); + if (e_contact_editor->name) + e_card_name_free(e_contact_editor->name); + g_free (e_contact_editor->company); gtk_object_unref(GTK_OBJECT(e_contact_editor->gui)); -- cgit v1.2.3