From 217e75d071c4de2305d44af930e7a6ebd7b453f0 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Tue, 17 Jul 2001 18:47:44 +0000 Subject: Removed old, broken code and annoying g_messages. 2001-07-17 Jon Trowbridge * backend/ebook/e-destination.c (e_destination_set_string): Removed old, broken code and annoying g_messages. * backend/ebook/e-book-listener.c (e_book_listener_queue_response): Hold a reference to the listener while the idle function is active. (e_book_listener_check_queue): Only release our reference to the listener when the queue is empty. These two changes fix a race condition, since the listener could be unrefed while the listener was still active. (Seems to fix bug #4485) svn path=/trunk/; revision=11164 --- addressbook/backend/ebook/e-book-listener.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addressbook/backend/ebook/e-book-listener.c') diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c index 7670a8b35d..dd682cbce4 100644 --- a/addressbook/backend/ebook/e-book-listener.c +++ b/addressbook/backend/ebook/e-book-listener.c @@ -33,7 +33,6 @@ struct _EBookListenerPrivate { static gboolean e_book_listener_check_queue (EBookListener *listener) { - gtk_object_ref (GTK_OBJECT (listener)); if (listener->priv->response_queue != NULL) { gtk_signal_emit (GTK_OBJECT (listener), e_book_listener_signals [RESPONSES_QUEUED]); @@ -41,11 +40,14 @@ e_book_listener_check_queue (EBookListener *listener) if (listener->priv->response_queue == NULL) { listener->priv->idle_id = 0; + + /* We only release our reference to the listener when the idle + function is totally finished. */ gtk_object_unref (GTK_OBJECT (listener)); + return FALSE; } - gtk_object_unref (GTK_OBJECT (listener)); return TRUE; } @@ -58,6 +60,10 @@ e_book_listener_queue_response (EBookListener *listener, response); if (listener->priv->idle_id == 0) { + + /* Hold a reference to the listener until the idle function is finished. */ + gtk_object_ref (GTK_OBJECT (listener)); + listener->priv->idle_id = g_idle_add ( (GSourceFunc) e_book_listener_check_queue, listener); } -- cgit v1.2.3