From 2890d2c2a1ffdd60f0540b04d7e569c0d8b84127 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Tue, 17 Jul 2001 19:38:18 +0000 Subject: Hold a reference to our listener while the idle function is active. 2001-07-17 Jon Trowbridge * backend/ebook/e-book-view-listener.c (e_book_view_listener_queue_response): Hold a reference to our listener while the idle function is active. (e_book_view_listener_check_queue): Only unref the listener when the idle function is finished. * gui/component/select-names/e-select-names-manager.c (e_select_names_clicked): Instead of replacing section->model with source, copy source onto section->model with e_select_names_model_overwrite_copy. #if 0/#endif out all of the stuff related to ETextModels, because it doesn't make any sense to me, and everything appears to work without it. (Die bug #2059. Die! Die! Die!) * gui/component/select-names/e-select-names-model.c (e_select_names_model_overwrite_copy): Added. Copies the contents of one ESelectNamesModel onto another. * backend/ebook/e-destination.c (e_destination_copy): Made the argument const. svn path=/trunk/; revision=11165 --- addressbook/ChangeLog | 21 +++++++++++++++++++++ addressbook/backend/ebook/e-book-view-listener.c | 22 ++++++++++++++-------- addressbook/backend/ebook/e-destination.c | 2 +- addressbook/backend/ebook/e-destination.h | 2 +- .../select-names/e-select-names-manager.c | 9 +++++---- .../component/select-names/e-select-names-model.c | 20 ++++++++++++++++++++ .../component/select-names/e-select-names-model.h | 11 ++++++----- 7 files changed, 68 insertions(+), 19 deletions(-) (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 564afc0e2e..480df273e7 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,5 +1,26 @@ 2001-07-17 Jon Trowbridge + * backend/ebook/e-book-view-listener.c + (e_book_view_listener_queue_response): Hold a reference to our + listener while the idle function is active. + (e_book_view_listener_check_queue): Only unref the listener when + the idle function is finished. + + * gui/component/select-names/e-select-names-manager.c + (e_select_names_clicked): Instead of replacing section->model with + source, copy source onto section->model with + e_select_names_model_overwrite_copy. #if 0/#endif out all of the + stuff related to ETextModels, because it doesn't make any sense to + me, and everything appears to work without it. + (Die bug #2059. Die! Die! Die!) + + * gui/component/select-names/e-select-names-model.c + (e_select_names_model_overwrite_copy): Added. Copies the contents + of one ESelectNamesModel onto another. + + * backend/ebook/e-destination.c (e_destination_copy): Made the argument + const. + * backend/ebook/e-destination.c (e_destination_set_string): Removed old, broken code and annoying g_messages. diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c index f1fd4d4519..d0323a9874 100644 --- a/addressbook/backend/ebook/e-book-view-listener.c +++ b/addressbook/backend/ebook/e-book-view-listener.c @@ -58,19 +58,21 @@ e_book_view_listener_check_queue (EBookViewListener *listener) else thrash = 0; - if (thrash > 20) { - g_error ("e_book_view_listener_check_queue thrashing!"); - thrash = 0; - listener->priv->idle_id = 0; - return FALSE; - } + if (thrash > 20 || listener->priv->response_queue == NULL) { - if (listener->priv->response_queue == NULL) { + if (thrash > 20) { + g_error ("e_book_view_listener_check_queue thrashing!"); + thrash = 0; + } + listener->priv->idle_id = 0; + + /* Only release our listener reference when the idle is finished. */ bonobo_object_unref (BONOBO_OBJECT (listener)); + return FALSE; } - bonobo_object_unref (BONOBO_OBJECT (listener)); + return TRUE; } @@ -84,6 +86,10 @@ e_book_view_listener_queue_response (EBookViewListener *listener, response); if (listener->priv->idle_id == 0) { + + /* Hold a reference to the listener while the idle is active. */ + gtk_object_ref (GTK_OBJECT (listener)); + listener->priv->idle_id = g_idle_add ( (GSourceFunc) e_book_view_listener_check_queue, listener); } diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c index 42377aaa33..f470769a2e 100644 --- a/addressbook/backend/ebook/e-destination.c +++ b/addressbook/backend/ebook/e-destination.c @@ -119,7 +119,7 @@ e_destination_new (void) } EDestination * -e_destination_copy (EDestination *dest) +e_destination_copy (const EDestination *dest) { EDestination *new_dest; GList *iter; diff --git a/addressbook/backend/ebook/e-destination.h b/addressbook/backend/ebook/e-destination.h index c4d742afbe..c53f255436 100644 --- a/addressbook/backend/ebook/e-destination.h +++ b/addressbook/backend/ebook/e-destination.h @@ -60,7 +60,7 @@ GtkType e_destination_get_type (void); EDestination *e_destination_new (void); -EDestination *e_destination_copy (EDestination *); +EDestination *e_destination_copy (const EDestination *); void e_destination_clear (EDestination *); gboolean e_destination_is_empty (EDestination *); diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index ead51d8dca..b255942d08 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -425,13 +425,13 @@ e_select_names_clicked(ESelectNames *dialog, gint button, ESelectNamesManager *m for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { ESelectNamesManagerSection *section = (void *) e_iterator_get(iterator); ESelectNamesModel *source = e_select_names_get_source(dialog, section->id); - if (section->model) - gtk_object_unref(GTK_OBJECT(section->model)); - section->model = source; - /* Don't ref because get_source returns a conceptual ref_count of 1. */ + e_select_names_model_overwrite_copy (section->model, source); + gtk_object_unref (GTK_OBJECT (source)); + } gtk_object_unref(GTK_OBJECT(iterator)); +#if 0 list = manager->entries; iterator = e_list_get_iterator(list); for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { @@ -449,6 +449,7 @@ e_select_names_clicked(ESelectNames *dialog, gint button, ESelectNamesManager *m } } gtk_object_unref(GTK_OBJECT(iterator)); +#endif break; } } diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index f102421f0e..dc383994d3 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -591,6 +591,26 @@ e_select_names_model_delete_all (ESelectNamesModel *model) e_select_names_model_changed (model); } +void +e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src) +{ + gint i, len; + + g_return_if_fail (dest && E_IS_SELECT_NAMES_MODEL (dest)); + g_return_if_fail (src && E_IS_SELECT_NAMES_MODEL (src)); + + if (src == dest) + return; + + e_select_names_model_delete_all (dest); + len = e_select_names_model_count (src); + for (i = 0; i < len; ++i) { + const EDestination *d = e_select_names_model_get_destination (src, i); + if (d) + e_select_names_model_append (dest, e_destination_copy (d)); + } +} + void e_select_names_model_name_pos (ESelectNamesModel *model, gint index, gint *pos, gint *length) { diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h index 330f1ddd82..b11e9503ec 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -61,11 +61,12 @@ void e_select_names_model_import_destinationv (ESelectNamesModel ECard *e_select_names_model_get_card (ESelectNamesModel *model, gint index); const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); -void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); -void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); -void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); -void e_select_names_model_delete (ESelectNamesModel *model, gint index); -void e_select_names_model_delete_all (ESelectNamesModel *model); +void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); +void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); +void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); +void e_select_names_model_delete (ESelectNamesModel *model, gint index); +void e_select_names_model_delete_all (ESelectNamesModel *model); +void e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src); void e_select_names_model_clean (ESelectNamesModel *model); -- cgit v1.2.3