From 0203f5de7608f34c6510948b36f522c4c3a87fef Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 14 May 2003 18:44:27 +0000 Subject: clear the view (book_open_cb): track the book in the view, don't unref the 2003-05-14 JP Rosevear * gui/component/addressbook.c (addressbook_view_unref): clear the view (book_open_cb): track the book in the view, don't unref the book (set_prop): set the book (retrieve_shell_view_interface_from_control): get the shell view every time (set_folder_bar_label): release and unref the shell view * gui/component/addressbook-storage.h: add proto * gui/component/addressbook-storage.c (addressbook_storage_cleanup): unref the storage * gui/component/addressbook-component.c (owner_unset_cb): clean up storage * backend/ebook/e-book.c (e_book_load_uri): track the listener signal (e_book_dispose): unref the listener and disconnect the signal svn path=/trunk/; revision=21179 --- addressbook/gui/component/addressbook-component.c | 2 + addressbook/gui/component/addressbook-storage.c | 9 +++ addressbook/gui/component/addressbook-storage.h | 1 + addressbook/gui/component/addressbook.c | 89 +++++++---------------- 4 files changed, 40 insertions(+), 61 deletions(-) (limited to 'addressbook/gui/component') diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index b1db690d2a..04a1e3ebe7 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -390,6 +390,8 @@ owner_unset_cb (EvolutionShellComponent *shell_component, if (owner_count == 0) global_shell_client = NULL; + + addressbook_storage_cleanup (); } /* FIXME We should perhaps take the time to figure out if the book is editable. */ diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c index 9b73b93b54..6f087b6c7e 100644 --- a/addressbook/gui/component/addressbook-storage.c +++ b/addressbook/gui/component/addressbook-storage.c @@ -107,6 +107,15 @@ addressbook_storage_setup (EvolutionShellComponent *shell_component, #endif } +void +addressbook_storage_cleanup (void) +{ + if (storage != NULL) { + bonobo_object_unref (storage); + storage = NULL; + } +} + #ifdef HAVE_LDAP static void notify_listener (const Bonobo_Listener listener, diff --git a/addressbook/gui/component/addressbook-storage.h b/addressbook/gui/component/addressbook-storage.h index 1d0fc24b73..9a26abebd6 100644 --- a/addressbook/gui/component/addressbook-storage.h +++ b/addressbook/gui/component/addressbook-storage.h @@ -64,6 +64,7 @@ typedef struct { void addressbook_storage_setup (EvolutionShellComponent *shell_component, const char *evolution_homedir); +void addressbook_storage_cleanup (void); EvolutionStorage *addressbook_get_other_contact_storage (void); GList *addressbook_storage_get_sources (void); diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 39c4f2fcce..1d7586f886 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -77,6 +77,7 @@ typedef struct { ESearchBar *search; gint ecml_changed_id; GtkWidget *vbox; + EBook *book; EvolutionActivityClient *activity; BonoboControl *control; BonoboPropertyBag *properties; @@ -422,23 +423,6 @@ control_activate_cb (BonoboControl *control, } } -static void -addressbook_view_ref (AddressbookView *view) -{ - g_assert (view->refs > 0); - ++view->refs; -} - -static void -addressbook_view_unref (AddressbookView *view) -{ - g_assert (view->refs > 0); - --view->refs; - if (view->refs == 0) { - g_free (view); - } -} - static ECategoriesMasterList * get_master_list (void) { @@ -452,24 +436,15 @@ get_master_list (void) static void addressbook_view_clear (AddressbookView *view) { - EBook *book; - - if (view->uri && view->view) { - g_object_get(view->view, - "book", &book, - NULL); - g_object_unref (book); + if (view->book) { + g_object_unref (view->book); + view->book = NULL; } if (view->properties) { bonobo_object_unref (BONOBO_OBJECT(view->properties)); view->properties = NULL; } - - if (view->view) { - gtk_widget_destroy (GTK_WIDGET (view->view)); - view->view = NULL; - } g_free(view->passwd); view->passwd = NULL; @@ -477,9 +452,6 @@ addressbook_view_clear (AddressbookView *view) g_free(view->uri); view->uri = NULL; - if (view->refs == 0) - g_free(view); - if (view->ecml_changed_id != 0) { g_signal_handler_disconnect (get_master_list(), view->ecml_changed_id); @@ -487,6 +459,24 @@ addressbook_view_clear (AddressbookView *view) } } +static void +addressbook_view_ref (AddressbookView *view) +{ + g_assert (view->refs > 0); + ++view->refs; +} + +static void +addressbook_view_unref (AddressbookView *view) +{ + g_assert (view->refs > 0); + --view->refs; + if (view->refs == 0) { + addressbook_view_clear (view); + g_free (view); + } +} + static void book_open_cb (EBook *book, EBookStatus status, gpointer closure) { @@ -494,10 +484,7 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure) if (status == E_BOOK_STATUS_SUCCESS) { view->failed_to_load = FALSE; - - g_object_set(view->view, - "book", book, - NULL); + view->book = book; } else { char *label_string; @@ -562,17 +549,12 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure) gtk_widget_show_all (warning_dialog); } - - g_object_unref (book); } static void destroy_callback(gpointer data, GObject *where_object_was) { AddressbookView *view = data; - if (view->view && view->view->model && view->view->model->book_view) - e_book_view_stop (view->view->model->book_view); - addressbook_view_clear (view); addressbook_view_unref (view); } @@ -767,20 +749,16 @@ set_prop (BonoboPropertyBag *bag, AddressbookView *view = user_data; char *uri_data; - EBook *book; switch (arg_id) { case PROPERTY_FOLDER_URI_IDX: - g_object_get(view->view, - "book", &book, - NULL); if (view->uri) { /* we've already had a uri set on this view, so unload it */ - e_book_unload_uri (book); + e_book_unload_uri (view->book); g_free (view->uri); } else { - book = e_book_new (); + view->book = e_book_new (); } view->failed_to_load = FALSE; @@ -789,7 +767,7 @@ set_prop (BonoboPropertyBag *bag, uri_data = e_book_expand_uri (view->uri); - addressbook_load_uri (book, uri_data, book_open_cb, view); + addressbook_load_uri (view->book, uri_data, book_open_cb, view); g_free(uri_data); @@ -920,12 +898,6 @@ retrieve_shell_view_interface_from_control (BonoboControl *control) GNOME_Evolution_ShellView shell_view_interface; CORBA_Environment ev; - shell_view_interface = g_object_get_data (G_OBJECT (control), - "shell_view_interface"); - - if (shell_view_interface) - return shell_view_interface; - control_frame = bonobo_control_get_control_frame (control, NULL); if (control_frame == NULL) @@ -937,13 +909,6 @@ retrieve_shell_view_interface_from_control (BonoboControl *control) &ev); CORBA_exception_free (&ev); - if (shell_view_interface != CORBA_OBJECT_NIL) - g_object_set_data (G_OBJECT (control), - "shell_view_interface", - shell_view_interface); - else - g_warning ("Control frame doesn't have Evolution/ShellView."); - return shell_view_interface; } @@ -1051,6 +1016,8 @@ set_folder_bar_label (EAddressbookView *eav, const char *message, AddressbookVie bonobo_exception_get_text (&ev)); CORBA_exception_free (&ev); + + bonobo_object_release_unref (shell_view_interface, NULL); } /* Our global singleton config database */ -- cgit v1.2.3