clear the view (book_open_cb): track the book in the view, don't unref the

2003-05-14  JP Rosevear  <jpr@ximian.com>

	* 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
This commit is contained in:
JP Rosevear
2003-05-14 18:44:27 +00:00
committed by JP Rosevear
parent d49d8a2f15
commit 0203f5de76
6 changed files with 72 additions and 64 deletions

View File

@ -1,3 +1,25 @@
2003-05-14 JP Rosevear <jpr@ximian.com>
* 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
2003-05-13 Chris Toshok <toshok@ximian.com>
* gui/component/select-names/e-select-names-text-model.c

View File

@ -57,6 +57,7 @@ struct _EBookPrivate {
gchar *uri;
gulong listener_signal;
gulong died_signal;
};
@ -773,8 +774,8 @@ e_book_load_uri (EBook *book,
return;
}
g_signal_connect (book->priv->listener, "responses_queued",
G_CALLBACK (e_book_check_listener_queue), book);
book->priv->listener_signal = g_signal_connect (book->priv->listener, "responses_queued",
G_CALLBACK (e_book_check_listener_queue), book);
load_uri_data = g_new (EBookLoadURIData, 1);
load_uri_data->open_response = open_response;
@ -1605,9 +1606,15 @@ e_book_dispose (GObject *object)
CORBA_exception_init (&ev);
}
}
CORBA_exception_free (&ev);
if (book->priv->listener) {
g_signal_handler_disconnect (book->priv->comp_listener, book->priv->listener_signal);
bonobo_object_unref (book->priv->listener);
book->priv->listener = NULL;
}
if (book->priv->comp_listener) {
g_signal_handler_disconnect (book->priv->comp_listener, book->priv->died_signal);
g_object_unref (book->priv->comp_listener);

View File

@ -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. */

View File

@ -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,

View File

@ -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);

View File

@ -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 */