diff options
author | Chris Toshok <toshok@ximian.com> | 2002-11-10 17:49:37 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2002-11-10 17:49:37 +0800 |
commit | 9aa24e5bd2d516b9722db784a16fd3ef838037a1 (patch) | |
tree | cf9bfd4dacba4a19b7c2b0d57d9d79757c7ed55d /addressbook/backend/ebook | |
parent | 28bc0361b9db902a9bcca18cfc5c1b9cc37a7229 (diff) | |
download | gsoc2013-evolution-9aa24e5bd2d516b9722db784a16fd3ef838037a1.tar.gz gsoc2013-evolution-9aa24e5bd2d516b9722db784a16fd3ef838037a1.tar.zst gsoc2013-evolution-9aa24e5bd2d516b9722db784a16fd3ef838037a1.zip |
guard against multiple invocations.
2002-11-10 Chris Toshok <toshok@ximian.com>
* backend/pas/pas-backend-card-sexp.c
(pas_backend_card_sexp_dispose): guard against multiple
invocations.
* backend/pas/pas-card-cursor.c (pas_card_cursor_dispose): same.
* backend/pas/pas-book.c (pas_book_dispose): same.
* backend/pas/pas-book-view.c (pas_book_view_dispose): same.
* backend/pas/pas-book-factory.c (pas_book_factory_dispose): same.
* backend/pas/pas-backend-summary.c (pas_backend_summary_dispose): same.
* backend/pas/pas-backend-ldap.c (pas_backend_ldap_dispose): same.
* backend/pas/pas-backend-file.c (pas_backend_file_dispose): same.
* backend/ebook/e-book-listener.c (e_book_listener_dispose): guard
against multiple invocations.
* backend/ebook/e-card.c (e_card_dispose): same.
* backend/ebook/e-card-simple.c (e_card_simple_dispose): same.
* backend/ebook/e-card-cursor.c (e_card_cursor_dispose): same.
* backend/ebook/e-book.c (e_book_dispose): same.
* backend/ebook/e-book-view-listener.c (e_book_view_listener_dispose): same.
svn path=/trunk/; revision=18687
Diffstat (limited to 'addressbook/backend/ebook')
-rw-r--r-- | addressbook/backend/ebook/e-book-listener.c | 35 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book-view-listener.c | 48 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book.c | 47 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card-cursor.c | 38 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card-simple.c | 47 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card.c | 72 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-destination.c | 17 |
7 files changed, 176 insertions, 128 deletions
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c index ffcd1fe127..6fb9b737ae 100644 --- a/addressbook/backend/ebook/e-book-listener.c +++ b/addressbook/backend/ebook/e-book-listener.c @@ -690,25 +690,32 @@ static void e_book_listener_dispose (GObject *object) { EBookListener *listener = E_BOOK_LISTENER (object); - GList *l; - /* Remove our response queue handler: In theory, this can never happen since we - always hold a reference to the listener while the timeout is running. */ - if (listener->priv->timeout_id) { - g_source_remove (listener->priv->timeout_id); - } + if (listener->priv) { + GList *l; - /* Clean up anything still sitting in response_queue */ - for (l = listener->priv->response_queue; l != NULL; l = l->next) { - EBookListenerResponse *resp = l->data; + /* Remove our response queue handler: In theory, this + can never happen since we always hold a reference + to the listener while the timeout is running. */ + if (listener->priv->timeout_id) { + g_source_remove (listener->priv->timeout_id); + } - response_free (resp); - } - g_list_free (listener->priv->response_queue); + /* Clean up anything still sitting in response_queue */ + for (l = listener->priv->response_queue; l != NULL; l = l->next) { + EBookListenerResponse *resp = l->data; - g_free (listener->priv); + response_free (resp); + } + g_list_free (listener->priv->response_queue); + + g_free (listener->priv); + + listener->priv = NULL; + } - G_OBJECT_CLASS (parent_class)->dispose (object); + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); } static void diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c index 1ac4a7ef83..fe50cf037b 100644 --- a/addressbook/backend/ebook/e-book-view-listener.c +++ b/addressbook/backend/ebook/e-book-view-listener.c @@ -374,35 +374,39 @@ static void e_book_view_listener_dispose (GObject *object) { EBookViewListener *listener = E_BOOK_VIEW_LISTENER (object); - GList *l; - - /* Remove our response queue handler: In theory, this can never happen since we - always hold a reference to the listener while the timeout is running. */ - if (listener->priv->timeout_id) { - g_source_remove (listener->priv->timeout_id); - } - /* Clear out the queue */ - for (l = listener->priv->response_queue; l != NULL; l = l->next) { - EBookViewListenerResponse *resp = l->data; + if (listener->priv) { + GList *l; + /* Remove our response queue handler: In theory, this + can never happen since we always hold a reference + to the listener while the timeout is running. */ + if (listener->priv->timeout_id) { + g_source_remove (listener->priv->timeout_id); + } - g_free(resp->id); + /* Clear out the queue */ + for (l = listener->priv->response_queue; l != NULL; l = l->next) { + EBookViewListenerResponse *resp = l->data; - g_list_foreach(resp->cards, (GFunc) g_object_unref, NULL); - g_list_free(resp->cards); - resp->cards = NULL; + g_free(resp->id); - g_free (resp->message); - resp->message = NULL; + g_list_foreach(resp->cards, (GFunc) g_object_unref, NULL); + g_list_free(resp->cards); + resp->cards = NULL; - g_free (resp); - } - g_list_free (listener->priv->response_queue); + g_free (resp->message); + resp->message = NULL; + + g_free (resp); + } + g_list_free (listener->priv->response_queue); - g_free (listener->priv); - listener->priv = NULL; + g_free (listener->priv); + listener->priv = NULL; + } - G_OBJECT_CLASS (parent_class)->dispose (object); + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); } static void diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c index 40938b1e8f..e236bc04ea 100644 --- a/addressbook/backend/ebook/e-book.c +++ b/addressbook/backend/ebook/e-book.c @@ -1477,35 +1477,42 @@ static void e_book_dispose (GObject *object) { EBook *book = E_BOOK (object); - CORBA_Environment ev; - GList *l; - if (book->priv->load_state == URILoaded) - e_book_unload_uri (book); + if (book->priv) { + CORBA_Environment ev; + GList *l; - CORBA_exception_init (&ev); + if (book->priv->load_state == URILoaded) + e_book_unload_uri (book); - for (l = book->priv->book_factories; l; l = l->next) { - CORBA_Object_release ((CORBA_Object)l->data, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EBook: Exception while releasing BookFactory\n"); + CORBA_exception_init (&ev); + + for (l = book->priv->book_factories; l; l = l->next) { + CORBA_Object_release ((CORBA_Object)l->data, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("EBook: Exception while releasing BookFactory\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); + CORBA_exception_free (&ev); + CORBA_exception_init (&ev); + } } - } - if (book->priv->comp_listener) { - g_signal_handler_disconnect (book->priv->comp_listener, book->priv->died_signal); - g_object_unref (book->priv->comp_listener); - book->priv->comp_listener = NULL; - } + CORBA_exception_free (&ev); - g_free (book->priv->uri); + if (book->priv->comp_listener) { + g_signal_handler_disconnect (book->priv->comp_listener, book->priv->died_signal); + g_object_unref (book->priv->comp_listener); + book->priv->comp_listener = NULL; + } + + g_free (book->priv->uri); - g_free (book->priv); + g_free (book->priv); + book->priv = NULL; + } - G_OBJECT_CLASS (parent_class)->dispose (object); + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); } static void diff --git a/addressbook/backend/ebook/e-card-cursor.c b/addressbook/backend/ebook/e-card-cursor.c index 4c96338a52..0aa9c8c1e0 100644 --- a/addressbook/backend/ebook/e-card-cursor.c +++ b/addressbook/backend/ebook/e-card-cursor.c @@ -26,32 +26,36 @@ static void e_card_cursor_dispose (GObject *object) { ECardCursor *cursor = E_CARD_CURSOR (object); - CORBA_Environment ev; - - CORBA_exception_init (&ev); - GNOME_Evolution_Addressbook_CardCursor_unref( cursor->priv->corba_cursor, &ev ); + if (cursor->priv) { + CORBA_Environment ev; - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_destroy: Exception unreffing " - "corba cursor.\n"); - CORBA_exception_free (&ev); CORBA_exception_init (&ev); - } - CORBA_Object_release (cursor->priv->corba_cursor, &ev); + GNOME_Evolution_Addressbook_CardCursor_unref( cursor->priv->corba_cursor, &ev ); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_destroy: Exception releasing " - "corba cursor.\n"); - } + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning("e_card_cursor_destroy: Exception unreffing " + "corba cursor.\n"); + CORBA_exception_free (&ev); + CORBA_exception_init (&ev); + } - CORBA_exception_free (&ev); + CORBA_Object_release (cursor->priv->corba_cursor, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning("e_card_cursor_destroy: Exception releasing " + "corba cursor.\n"); + } + + CORBA_exception_free (&ev); - if ( cursor->priv ) g_free ( cursor->priv ); + cursor->priv = NULL; + } - G_OBJECT_CLASS (parent_class)->dispose (object); + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); } /** diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c index b033b81d55..6b1f057c22 100644 --- a/addressbook/backend/ebook/e-card-simple.c +++ b/addressbook/backend/ebook/e-card-simple.c @@ -349,22 +349,43 @@ e_card_simple_dispose (GObject *object) simple = E_CARD_SIMPLE (object); - if (simple->card) + if (simple->card) { g_object_unref(simple->card); - g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL); - g_list_free(simple->temp_fields); - simple->temp_fields = NULL; + simple->card = NULL; + } + if (simple->temp_fields) { + g_list_foreach(simple->temp_fields, (GFunc) g_free, NULL); + g_list_free(simple->temp_fields); + simple->temp_fields = NULL; + } - for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) - e_card_phone_unref (simple->phone[i]); - for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) - g_free(simple->email[i]); - for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) - e_card_address_label_unref(simple->address[i]); - for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) - e_card_delivery_address_unref(simple->delivery[i]); + for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) { + if (simple->phone[i]) { + e_card_phone_unref (simple->phone[i]); + simple->phone[i] = NULL; + } + } + for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) { + if (simple->email[i]) { + g_free(simple->email[i]); + simple->email[i] = NULL; + } + } + for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { + if (simple->address[i]) { + e_card_address_label_unref(simple->address[i]); + simple->address[i] = NULL; + } + } + for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { + if (simple->delivery[i]) { + e_card_delivery_address_unref(simple->delivery[i]); + simple->delivery[i] = NULL; + } + } - G_OBJECT_CLASS (parent_class)->dispose (object); + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); } diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c index f98269dff5..07926ddd84 100644 --- a/addressbook/backend/ebook/e-card.c +++ b/addressbook/backend/ebook/e-card.c @@ -1997,42 +1997,44 @@ static void e_card_dispose (GObject *object) { ECard *card = E_CARD(object); - g_free(card->id); - if (card->book) - g_object_unref (card->book); - g_free(card->file_as); - g_free(card->fname); - e_card_name_unref(card->name); - g_free(card->bday); - - g_free(card->url); - g_free(card->org); - g_free(card->org_unit); - g_free(card->office); - g_free(card->title); - g_free(card->role); - g_free(card->manager); - g_free(card->assistant); - g_free(card->nickname); - g_free(card->spouse); - g_free(card->anniversary); - g_free(card->caluri); - g_free(card->fburl); - g_free(card->note); - g_free(card->related_contacts); - if (card->categories) - g_object_unref(card->categories); - if (card->email) - g_object_unref(card->email); - if (card->phone) - g_object_unref(card->phone); - if (card->address) - g_object_unref(card->address); - if (card->address_label) - g_object_unref(card->address_label); - - G_OBJECT_CLASS (parent_class)->dispose (object); +#define FREE_IF(x) do { if ((x)) { g_free (x); x = NULL; } } while (0) +#define UNREF_IF(x) do { if ((x)) { g_object_unref (x); x = NULL; } } while (0) + + FREE_IF (card->id); + UNREF_IF (card->book); + FREE_IF(card->file_as); + FREE_IF(card->fname); + if (card->name) { + e_card_name_unref(card->name); + card->name = NULL; + } + FREE_IF(card->bday); + + FREE_IF(card->url); + FREE_IF(card->org); + FREE_IF(card->org_unit); + FREE_IF(card->office); + FREE_IF(card->title); + FREE_IF(card->role); + FREE_IF(card->manager); + FREE_IF(card->assistant); + FREE_IF(card->nickname); + FREE_IF(card->spouse); + FREE_IF(card->anniversary); + FREE_IF(card->caluri); + FREE_IF(card->fburl); + FREE_IF(card->note); + FREE_IF(card->related_contacts); + + UNREF_IF (card->categories); + UNREF_IF (card->email); + UNREF_IF (card->phone); + UNREF_IF (card->address); + UNREF_IF (card->address_label); + + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); } diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c index 6537ea7480..86108125cb 100644 --- a/addressbook/backend/ebook/e-destination.c +++ b/addressbook/backend/ebook/e-destination.c @@ -96,17 +96,20 @@ e_destination_dispose (GObject *obj) { EDestination *dest = E_DESTINATION (obj); - e_destination_clear (dest); + if (dest->priv) { + e_destination_clear (dest); - if (dest->priv->old_card) - g_object_unref (dest->priv->old_card); + if (dest->priv->old_card) + g_object_unref (dest->priv->old_card); - if (dest->priv->cardify_book) - g_object_unref (dest->priv->cardify_book); + if (dest->priv->cardify_book) + g_object_unref (dest->priv->cardify_book); - g_free (dest->priv->old_textrep); + g_free (dest->priv->old_textrep); - g_free (dest->priv); + g_free (dest->priv); + dest->priv = NULL; + } } static void |