From 4778e69589b8d5fca5b59cdb664b8e6e39a4697f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 23 Jun 2011 18:30:36 +0200 Subject: Postpone ENameSelector loading as much as possible Also fixes few memory leaks around ENameSelector and cancels loading of its address books when not needed any more. --- calendar/gui/dialogs/alarm-dialog.c | 5 +++++ calendar/gui/dialogs/e-delegate-dialog.c | 2 ++ calendar/gui/dialogs/memo-page.c | 6 ++++++ calendar/gui/e-meeting-list-view.c | 14 ++++++++++++++ 4 files changed, 27 insertions(+) (limited to 'calendar') diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c index 564c4dd1f4..ec57b11657 100644 --- a/calendar/gui/dialogs/alarm-dialog.c +++ b/calendar/gui/dialogs/alarm-dialog.c @@ -903,6 +903,7 @@ setup_select_names (Dialog *dialog) ENameSelectorDialog *name_selector_dialog; dialog->name_selector = e_name_selector_new (); + e_name_selector_load_books (dialog->name_selector); name_selector_model = e_name_selector_peek_model (dialog->name_selector); e_name_selector_model_add_section (name_selector_model, section_name, section_name, NULL); @@ -1229,6 +1230,10 @@ alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm if (response_id == GTK_RESPONSE_OK) dialog_to_alarm (&dialog); + if (dialog.name_selector) { + e_name_selector_cancel_loading (dialog.name_selector); + g_object_unref (dialog.name_selector); + } gtk_widget_destroy (dialog.toplevel); g_object_unref (dialog.builder); diff --git a/calendar/gui/dialogs/e-delegate-dialog.c b/calendar/gui/dialogs/e-delegate-dialog.c index 2bca1c908b..da6eeea05d 100644 --- a/calendar/gui/dialogs/e-delegate-dialog.c +++ b/calendar/gui/dialogs/e-delegate-dialog.c @@ -96,6 +96,7 @@ e_delegate_dialog_finalize (GObject *object) edd = E_DELEGATE_DIALOG (object); priv = edd->priv; + e_name_selector_cancel_loading (priv->name_selector); g_object_unref (priv->name_selector); /* Destroy the actual dialog. */ @@ -137,6 +138,7 @@ e_delegate_dialog_construct (EDelegateDialog *edd, const gchar *name, const gcha } priv->name_selector = e_name_selector_new (); + e_name_selector_load_books (priv->name_selector); name_selector_model = e_name_selector_peek_model (priv->name_selector); e_name_selector_model_add_section (name_selector_model, section_name, section_name, NULL); diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index d720e91b1d..3a53421dd5 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -202,6 +202,12 @@ memo_page_finalize (GObject *object) priv = MEMO_PAGE (object)->priv; + if (priv->name_selector) { + e_name_selector_cancel_loading (priv->name_selector); + g_object_unref (priv->name_selector); + priv->name_selector = NULL; + } + if (priv->main != NULL) { g_object_unref (priv->main); priv->main = NULL; diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c index 11f47e6030..5283b5e385 100644 --- a/calendar/gui/e-meeting-list-view.c +++ b/calendar/gui/e-meeting-list-view.c @@ -82,6 +82,7 @@ e_meeting_list_view_finalize (GObject *obj) EMeetingListViewPrivate *priv = view->priv; if (priv->name_selector) { + e_name_selector_cancel_loading (priv->name_selector); g_object_unref (priv->name_selector); priv->name_selector = NULL; } @@ -126,6 +127,17 @@ add_section (ENameSelector *name_selector, const gchar *name) e_name_selector_model_add_section (name_selector_model, name, gettext (name), NULL); } +static void +meeting_list_view_realize_cb (EMeetingListView *view) +{ + g_return_if_fail (view != NULL); + g_return_if_fail (view->priv != NULL); + + g_signal_handlers_disconnect_by_func (view, meeting_list_view_realize_cb, NULL); + + e_name_selector_load_books (view->priv->name_selector); +} + static void e_meeting_list_view_init (EMeetingListView *view) { @@ -149,6 +161,8 @@ e_meeting_list_view_init (EMeetingListView *view) g_signal_connect (name_selector_dialog, "response", G_CALLBACK (name_selector_dialog_close_cb), view); + /* postpone name_selector loading, do that only when really needed */ + g_signal_connect (view, "realize", G_CALLBACK (meeting_list_view_realize_cb), NULL); } static GList * -- cgit v1.2.3