From d55b4a5e61e0e58d861bb4c5efa007b81963fdb6 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Thu, 17 Apr 2008 08:34:18 +0000 Subject: [PATCH] * Fixed two callbacks in the main window that were taking wrong arguments * Fixed a reference leak when unregistering windows * Removed window handling code from modest-main * Fixed a couple memory issues found by valgrind when unregistering windows pmo-trunk-r4426 --- src/maemo/modest-main-window.c | 10 +++++----- src/modest-main.c | 8 -------- src/widgets/modest-window-mgr.c | 23 ++++++++++++++--------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index 3023683..d997f0b 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -2826,19 +2826,19 @@ on_window_hide (GObject *gobject, GParamSpec *arg1, gpointer user_data) { - g_return_if_fail (MODEST_IS_MAIN_WINDOW (user_data)); + g_return_if_fail (MODEST_IS_MAIN_WINDOW (gobject)); - if (!GTK_WIDGET_VISIBLE (user_data)) - remove_banners (MODEST_MAIN_WINDOW (user_data)); + if (!GTK_WIDGET_VISIBLE (gobject)) + remove_banners (MODEST_MAIN_WINDOW (gobject)); } static void on_window_destroy (GtkObject *widget, gpointer user_data) { - g_return_if_fail (MODEST_IS_MAIN_WINDOW (user_data)); + g_return_if_fail (MODEST_IS_MAIN_WINDOW (widget)); - remove_banners (MODEST_MAIN_WINDOW (user_data)); + remove_banners (MODEST_MAIN_WINDOW (widget)); } static gboolean diff --git a/src/modest-main.c b/src/modest-main.c index 269f06d..b330ca2 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -45,8 +45,6 @@ typedef struct { static gboolean on_idle_exit_modest (gpointer data) { - ModestWindow *main_win; - ModestWindowMgr *mgr; MainSignalHandlers *handlers; /* Protect the Gtk calls */ @@ -59,12 +57,6 @@ on_idle_exit_modest (gpointer data) g_signal_handler_disconnect (modest_runtime_get_window_mgr (), handlers->window_list_handler); - /* If the main window is still there but hidden, then unregister it */ - mgr = modest_runtime_get_window_mgr(); - main_win = modest_window_mgr_get_main_window (mgr, FALSE); - if (main_win) - modest_window_mgr_unregister_window (mgr, main_win); - /* Wait for remaining tasks */ while (gtk_events_pending ()) gtk_main_iteration (); diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 81b70b8..567f989 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -246,6 +246,7 @@ modest_window_mgr_finalize (GObject *obj) } modest_signal_mgr_disconnect_all_and_destroy (priv->window_state_uids); + priv->window_state_uids = NULL; if (priv->window_list) { GList *iter = priv->window_list; @@ -275,6 +276,7 @@ modest_window_mgr_finalize (GObject *obj) } modest_signal_mgr_disconnect_all_and_destroy (priv->modal_handler_uids); + priv->modal_handler_uids = NULL; if (priv->modal_windows) { g_mutex_lock (priv->queue_lock); @@ -914,15 +916,19 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self, cancel_window_operations (window); /* Disconnect the "window-state-event" handler, we won't need it anymore */ + if (priv->window_state_uids) { #ifdef MODEST_PLATFORM_MAEMO - priv->window_state_uids = modest_signal_mgr_disconnect (priv->window_state_uids, - G_OBJECT (window), - "notify::is-topmost"); + priv->window_state_uids = + modest_signal_mgr_disconnect (priv->window_state_uids, + G_OBJECT (window), + "notify::is-topmost"); #else - priv->window_state_uids = modest_signal_mgr_disconnect (priv->window_state_uids, - G_OBJECT (window), - "window-state-event"); + priv->window_state_uids = + modest_signal_mgr_disconnect (priv->window_state_uids, + G_OBJECT (window), + "window-state-event"); #endif + } /* Disconnect the "delete-event" handler, we won't need it anymore */ g_signal_handler_disconnect (window, handler_id); @@ -930,12 +936,12 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self, /* Disconnect all the window signals */ modest_window_disconnect_signals (window); - /* Destroy the window */ + /* Destroy the window and unref the extra reference */ + g_object_unref (win->data); gtk_widget_destroy (win->data); /* If there are no more windows registered emit the signal */ if (modest_window_mgr_num_windows (self) == 0) -/* if (priv->window_list == NULL && priv->banner_counter == 0) */ g_signal_emit (self, signals[WINDOW_LIST_EMPTY_SIGNAL], 0); } @@ -1378,7 +1384,6 @@ modest_window_mgr_unregister_banner (ModestWindowMgr *self) priv = MODEST_WINDOW_MGR_GET_PRIVATE (self); priv->banner_counter--; -/* if (priv->window_list == NULL && priv->banner_counter == 0) */ if (modest_window_mgr_num_windows (self) == 0) g_signal_emit (self, signals[WINDOW_LIST_EMPTY_SIGNAL], 0); } -- 1.7.9.5