* src/widgets/modest-window-mgr.c:
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 24 Jun 2008 17:39:17 +0000 (17:39 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 24 Jun 2008 17:39:17 +0000 (17:39 +0000)
        * As ..._unregister_window frees the g_list node, changed the
          order to fetch first the next element in list before we
          destroy the reference to the list.
        * Now on_window_destroy never propagates, as we take care of
          destroy.
        * The window mgr window list contains now a explicit GObject
          reference, and we free this one on removing elements from it.
* src/modest-ui-actions.c:
        * On creating view and edit windows, we don't unref them as
          these references are the floating ones (handled by gtk).
* src/modest-main-window.c:
        * Keep an explicit reference to empty view and header view
          to be able to free them properly on finishing the main
          window.
        * Fix a reference leak to folder store on calling to sync folder
          mail operation.

pmo-trunk-r4766

src/maemo/modest-main-window.c
src/modest-runtime.c
src/modest-ui-actions.c
src/widgets/modest-window-mgr.c

index 620e6f1..009d325 100644 (file)
@@ -389,6 +389,16 @@ modest_main_window_finalize (GObject *obj)
           call this function before */
        modest_main_window_disconnect_signals (MODEST_WINDOW (obj));    
        modest_main_window_cleanup_queue_error_signals ((ModestMainWindow *) obj);
+
+       if (priv->empty_view) {
+               g_object_unref (priv->empty_view);
+               priv->empty_view = NULL;
+       }
+       
+       if (priv->header_view) {
+               g_object_unref (priv->header_view);
+               priv->header_view = NULL;
+       }
        
        g_slist_free (priv->progress_widgets);
 
@@ -1274,6 +1284,7 @@ modest_main_window_new (void)
        /* header view */
        priv->header_view =
                MODEST_HEADER_VIEW (modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS));
+       g_object_ref (priv->header_view);
        if (!priv->header_view)
                g_printerr ("modest: cannot instantiate header view\n");
        modest_header_view_set_style (priv->header_view, MODEST_HEADER_VIEW_STYLE_TWOLINES);
@@ -1289,6 +1300,7 @@ modest_main_window_new (void)
        /* Empty view */ 
        priv->empty_view = create_empty_view ();
        gtk_widget_show (priv->empty_view);
+       g_object_ref (priv->empty_view);
                 
        /* Create scrolled windows */
        folder_win = gtk_scrolled_window_new (NULL, NULL);
@@ -2042,10 +2054,7 @@ modest_main_window_set_contents_style (ModestMainWindow *self,
           details widget */
        GtkWidget *content = gtk_bin_get_child (GTK_BIN (priv->contents_widget));
        if (content) {
-               if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)
-                       g_object_ref (content);
-               else if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY) {
-                       g_object_ref (priv->empty_view);
+               if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY) {
                        gtk_container_remove (GTK_CONTAINER (content), priv->empty_view);
                }
                
@@ -2872,6 +2881,7 @@ on_window_hide (GObject    *gobject,
                                                         mail_op);
                        modest_mail_operation_sync_folder (mail_op, TNY_FOLDER (folder_store), FALSE);
                        g_object_unref (mail_op);
+                       g_object_unref (folder_store);
                }
        }
 }
index 7b1f186..487f9a7 100644 (file)
@@ -86,7 +86,7 @@ modest_runtime_uninit (void)
                return TRUE;    /* uninit maybe called if runtime_init failed */
        
        g_return_val_if_fail (MODEST_IS_SINGLETONS(_singletons), FALSE);
-       
+
        g_debug ("%s: cleaning up", __FUNCTION__);
 
        if (_sig_handlers) {
index 614ba87..cb52073 100644 (file)
@@ -783,8 +783,6 @@ cleanup:
                g_object_unref (G_OBJECT(account));
        if (folder)
                g_object_unref (G_OBJECT(folder));
-       if (msg_win)
-               g_object_unref (G_OBJECT(msg_win));
        if (msg)
                g_object_unref (G_OBJECT(msg));
 }
@@ -996,7 +994,6 @@ open_msg_cb (ModestMailOperation *mail_op,
        if (win != NULL) {
                mgr = modest_runtime_get_window_mgr ();
                modest_window_mgr_register_window (mgr, win);
-               g_object_unref (win);
                gtk_widget_show_all (GTK_WIDGET(win));
        }
 
@@ -1592,8 +1589,6 @@ reply_forward_cb (ModestMailOperation *mail_op,
        gtk_widget_show_all (GTK_WIDGET (msg_win));
 
 cleanup:
-       if (msg_win)
-               g_object_unref (msg_win);
        if (new_msg)
                g_object_unref (G_OBJECT (new_msg));
        if (account)
index e32ae57..1fefe35 100644 (file)
@@ -255,9 +255,9 @@ modest_window_mgr_finalize (GObject *obj)
                GList *iter = priv->window_list;
                /* unregister pending windows */
                while (iter) {
-                       modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), 
-                                                            MODEST_WINDOW (iter->data));
+                       ModestWindow *window = (ModestWindow *) iter->data;
                        iter = g_list_next (iter);
+                       modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), window);
                }
                g_list_free (priv->window_list);
                priv->window_list = NULL;
@@ -817,7 +817,7 @@ on_window_destroy (ModestWindow *window,
                }
                /* Unregister window */
                modest_window_mgr_unregister_window (self, window);
-               no_propagate = FALSE;
+               no_propagate = TRUE;
        }
 
        return no_propagate;
@@ -889,6 +889,7 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self,
        priv->window_list = g_list_remove_link (priv->window_list, win);
        tmp = g_hash_table_lookup (priv->destroy_handlers, window);
        handler_id = *tmp;
+
        g_hash_table_remove (priv->destroy_handlers, window);
 
        /* cancel open and receive operations */
@@ -923,7 +924,9 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self,
        modest_window_disconnect_signals (window);
        
        /* Destroy the window */
+       g_object_unref (win->data);
        gtk_widget_destroy (win->data);
+       g_list_free (win);
        
        /* If there are no more windows registered emit the signal */
        if (modest_window_mgr_num_windows (self) == 0)