From e4c70cd2f525f80332946c788dc57b38e2926eba Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Thu, 30 Aug 2001 03:28:56 +0000 Subject: This function can be re-entrant during the signal emission; Added extra 2001-08-29 Jon Trowbridge * backend/ebook/e-book-listener.c (e_book_listener_check_queue): This function can be re-entrant during the signal emission; Added extra ref/unrefs and checks to avoid problems if this happens. This is similar to my recent changes to e_book_view_listener_check_queue. (Fixes bug #7400) svn path=/trunk/; revision=12523 --- addressbook/backend/ebook/e-book-listener.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 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 aa05a87a2b..15ceb04bd3 100644 --- a/addressbook/backend/ebook/e-book-listener.c +++ b/addressbook/backend/ebook/e-book-listener.c @@ -35,22 +35,32 @@ struct _EBookListenerPrivate { static gboolean e_book_listener_check_queue (EBookListener *listener) { + gboolean retval; + + /* Hold a reference locally, so that we can't get blown away + during the signal emission. */ + bonobo_object_ref (BONOBO_OBJECT (listener)); + retval = TRUE; + if (listener->priv->response_queue != NULL) { gtk_signal_emit (GTK_OBJECT (listener), e_book_listener_signals [RESPONSES_QUEUED]); } - if (listener->priv->response_queue == NULL) { + /* Make sure that ->idle_id != 0, so that only the first reentrant call to + this function unrefs our "global" reference. */ + if (listener->priv->response_queue == NULL && listener->priv->idle_id != 0) { listener->priv->idle_id = 0; /* We only release our reference to the listener when the idle function is totally finished. */ bonobo_object_unref (BONOBO_OBJECT (listener)); - - return FALSE; + retval = FALSE; } - return TRUE; + bonobo_object_unref (BONOBO_OBJECT (listener)); + + return retval; } static void -- cgit v1.2.3