diff options
author | Jon Trowbridge <trow@ximian.com> | 2001-08-30 12:14:17 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-08-30 12:14:17 +0800 |
commit | 206e67a5a62ea3f142c6fb60998dbd3b435ddee4 (patch) | |
tree | 797715f87878433773d6073bc874fb6bde0abdf0 /addressbook/gui/contact-editor/e-contact-quick-add.c | |
parent | 1cae0f1a15d107fd0f514b8a64ecfdf4af4768be (diff) | |
download | gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.tar gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.tar.gz gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.tar.bz2 gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.tar.lz gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.tar.xz gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.tar.zst gsoc2013-evolution-206e67a5a62ea3f142c6fb60998dbd3b435ddee4.zip |
Paranoia. Check that name != qa->name. (quick_add_set_email): Check that
2001-08-29 Jon Trowbridge <trow@ximian.com>
* gui/contact-editor/e-contact-quick-add.c (quick_add_set_name):
Paranoia. Check that name != qa->name.
(quick_add_set_email): Check that email != qa->email.
(ce_have_book): Store the QuickAdd data structure in object data,
so that we can be extra-careful and avoid having a dangling
pointer floating around out somewhere as the closure for a signal.
Fixes bug #8155, I think.
(card_added_cb): Clear object data to ensure single unref.
(editor_closed_cb): Clear object data to ensure single unref.
svn path=/trunk/; revision=12525
Diffstat (limited to 'addressbook/gui/contact-editor/e-contact-quick-add.c')
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-quick-add.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c index 27755d980a..30c67a53ba 100644 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ b/addressbook/gui/contact-editor/e-contact-quick-add.c @@ -97,6 +97,9 @@ quick_add_set_name (QuickAdd *qa, const gchar *name) { ECardSimple *simple; + if (name == qa->name) + return; + g_free (qa->name); qa->name = g_strdup (name); @@ -111,6 +114,9 @@ quick_add_set_email (QuickAdd *qa, const gchar *email) { ECardSimple *simple; + if (email == qa->email) + return; + g_free (qa->email); qa->email = g_strdup (email); @@ -153,21 +159,28 @@ quick_add_merge_card (QuickAdd *qa) static void card_added_cb (EContactEditor *ce, EBookStatus status, ECard *card, gpointer closure) { - QuickAdd *qa = (QuickAdd *) closure; + QuickAdd *qa = (QuickAdd *) gtk_object_get_data (GTK_OBJECT (ce), "quick_add"); - if (qa->cb) - qa->cb (qa->card, qa->closure); + if (qa) { + + if (qa->cb) + qa->cb (qa->card, qa->closure); - quick_add_unref (qa); + quick_add_unref (qa); + gtk_object_set_data (GTK_OBJECT (ce), "quick_add", NULL); + } } static void editor_closed_cb (GtkWidget *w, gpointer closure) { - QuickAdd *qa = (QuickAdd *) closure; - g_warning ("editor_closed_cb"); - quick_add_unref (qa); - gtk_object_unref (GTK_OBJECT (w)); + QuickAdd *qa = (QuickAdd *) gtk_object_get_data (GTK_OBJECT (w), "quick_add"); + + if (qa) { + quick_add_unref (qa); + gtk_object_set_data (GTK_OBJECT (w), "quick_add", NULL); + gtk_object_unref (GTK_OBJECT (w)); + } } static void @@ -186,14 +199,20 @@ ce_have_book (EBook *book, gpointer closure) "changed", TRUE, NULL); + /* We pass this via object data, so that we don't get a dangling pointer referenced if both + the "card_added" and "editor_closed" get emitted. (Which, based on a backtrace in bugzilla, + I think can happen and cause a crash. */ + gtk_object_set_data_full (GTK_OBJECT (contact_editor), "quick_add", qa, + (GtkDestroyNotify) quick_add_unref); + gtk_signal_connect (GTK_OBJECT (contact_editor), "card_added", GTK_SIGNAL_FUNC (card_added_cb), - qa); + NULL); gtk_signal_connect (GTK_OBJECT (contact_editor), "editor_closed", GTK_SIGNAL_FUNC (editor_closed_cb), - qa); + NULL); } } |