Fixed some reference leaks
authorSergio Villar Senin <svillar@igalia.com>
Wed, 21 Feb 2007 17:56:19 +0000 (17:56 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 21 Feb 2007 17:56:19 +0000 (17:56 +0000)
pmo-trunk-r846

src/gtk/modest-account-view-window.c
src/maemo/modest-account-view-window.c
src/modest-tny-account-store.c
src/widgets/modest-account-view.c
src/widgets/modest-account-view.h
src/widgets/modest-folder-view.c

index ef283a4..bc915f0 100644 (file)
@@ -102,13 +102,6 @@ modest_account_view_window_class_init (ModestAccountViewWindowClass *klass)
        gobject_class->finalize = modest_account_view_window_finalize;
 
        g_type_class_add_private (gobject_class, sizeof(ModestAccountViewWindowPrivate));
-
-       /* signal definitions go here, e.g.: */
-/*     signals[MY_SIGNAL_1] = */
-/*             g_signal_new ("my_signal_1",....); */
-/*     signals[MY_SIGNAL_2] = */
-/*             g_signal_new ("my_signal_2",....); */
-/*     etc. */
 }
 
 static void
@@ -131,7 +124,7 @@ on_selection_changed (GtkTreeSelection *sel, ModestAccountViewWindow *self)
        GtkTreeModel                   *model;
        GtkTreeIter                    iter;
        gboolean                       has_selection;
-       const gchar                   *account_name;
+       gchar                         *account_name;
        gchar                         *default_account_name;
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
@@ -148,6 +141,7 @@ on_selection_changed (GtkTreeSelection *sel, ModestAccountViewWindow *self)
        gtk_widget_set_sensitive (priv->default_button,
                                  default_account_name == NULL || account_name == NULL ||
                                  strcmp (default_account_name, account_name) != 0);
+       g_free (account_name);
        g_free (default_account_name);
 }
 
@@ -156,7 +150,7 @@ on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 {
        ModestAccountViewWindowPrivate *priv;
        ModestAccountMgr *account_mgr;
-       const gchar *account_name;
+       gchar *account_name;
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
@@ -179,7 +173,7 @@ on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
                txt = g_strdup_printf (_("Do you really want to delete the account %s?"), account_name);
                gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), 
                                    gtk_label_new (txt), FALSE, FALSE, 0);
-               gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
+/*             gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); */
                g_free (txt);
 
                if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
@@ -192,9 +186,11 @@ on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
                                /* Show confirmation dialog ??? */
                        } else {
                                /* Show error dialog ??? */
+                               g_warning ("Error removing account %s", account_name);
                        }
                }
                gtk_widget_destroy (dialog);
+               g_free (account_name);
        }
 }
 
@@ -224,7 +220,7 @@ on_default_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 {
        ModestAccountViewWindowPrivate *priv;
        ModestAccountMgr *account_mgr;
-       const gchar *account_name;
+       gchar *account_name;
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
@@ -232,6 +228,8 @@ on_default_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
        account_name = modest_account_view_get_selected_account (priv->account_view);
 
        modest_account_mgr_set_default_account (account_mgr, account_name);
+
+       g_free (account_name);
 }
 
 
index 9b08c8e..c499729 100644 (file)
@@ -129,10 +129,10 @@ on_selection_changed (GtkTreeSelection *sel, ModestAccountViewWindow *self)
 {
        ModestAccountViewWindowPrivate *priv;
        GtkTreeModel                   *model;
-       GtkTreeIter                    iter;
-       gboolean                       has_selection;
-       const gchar                   *account_name;
-       gchar                         *default_account_name;
+       GtkTreeIter                     iter;
+       gboolean                        has_selection;
+       gchar                          *account_name;
+       gchar                          *default_account_name;
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
@@ -148,6 +148,7 @@ on_selection_changed (GtkTreeSelection *sel, ModestAccountViewWindow *self)
        gtk_widget_set_sensitive (priv->default_button,
                                  default_account_name == NULL || account_name == NULL ||
                                  strcmp (default_account_name, account_name) != 0);
+       g_free (account_name);
        g_free (default_account_name);
 }
 
@@ -156,7 +157,7 @@ on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 {
        ModestAccountViewWindowPrivate *priv;
        ModestAccountMgr *account_mgr;
-       const gchar *account_name;
+       gchar *account_name;
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
@@ -195,6 +196,7 @@ on_remove_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
                        }
                }
                gtk_widget_destroy (dialog);
+               g_free (account_name);
        }
 }
 
@@ -228,7 +230,7 @@ on_default_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 {
        ModestAccountViewWindowPrivate *priv;
        ModestAccountMgr *account_mgr;
-       const gchar *account_name;
+       gchar *account_name;
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
@@ -236,6 +238,8 @@ on_default_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
        account_name = modest_account_view_get_selected_account (priv->account_view);
 
        modest_account_mgr_set_default_account (account_mgr, account_name);
+
+       g_free (account_name);
 }
 
 
index 273ef8b..558cb0c 100644 (file)
@@ -386,7 +386,7 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, TnyDevice *device)
 
        GObject *obj;
        ModestTnyAccountStorePrivate *priv;
-       TnyList *list;
+/*     TnyList *list; */
        
        g_return_val_if_fail (account_mgr, NULL);
        g_return_val_if_fail (device, NULL);
index e2864d7..eef4aa5 100644 (file)
@@ -260,7 +260,6 @@ bold_if_default_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer *rendere
                      NULL);
 }
 
-
 static void
 init_view (ModestAccountView *self)
 {
@@ -281,6 +280,7 @@ init_view (ModestAccountView *self)
                ); 
 
        gtk_tree_view_set_model (GTK_TREE_VIEW(self), GTK_TREE_MODEL(model));
+       g_object_unref (G_OBJECT (model));
 
        toggle_renderer = gtk_cell_renderer_toggle_new ();
        text_renderer = gtk_cell_renderer_text_new ();
@@ -343,10 +343,10 @@ modest_account_view_new (ModestAccountMgr *account_mgr)
        return MODEST_ACCOUNT_VIEW(obj);
 }
 
-const gchar *
+gchar *
 modest_account_view_get_selected_account (ModestAccountView *self)
 {
-       const gchar *account_name = NULL;
+       gchar *account_name = NULL;
        GtkTreeSelection *sel;
        GtkTreeModel *model;
        GtkTreeIter iter;
@@ -355,8 +355,9 @@ modest_account_view_get_selected_account (ModestAccountView *self)
        
        sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
        if (gtk_tree_selection_get_selected (sel, &model, &iter)) {
-               gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name,
-                                   -1);
+               gtk_tree_model_get (model, &iter, 
+                                   MODEST_ACCOUNT_VIEW_NAME_COLUMN, 
+                                   &account_name, -1);
        }
 
        return account_name;
index fcc8ea2..aa16dd2 100644 (file)
@@ -85,7 +85,7 @@ ModestAccountView*   modest_account_view_new         (ModestAccountMgr *account_
  * Returns: the name of the selected account or NULL if none is
  * selected
  **/
-const gchar*   modest_account_view_get_selected_account    (ModestAccountView *account_view);
+gchar*   modest_account_view_get_selected_account    (ModestAccountView *account_view);
 
 G_END_DECLS
 
index e619794..563d313 100644 (file)
@@ -699,37 +699,37 @@ modest_folder_view_get_selected (ModestFolderView *self)
        return priv->cur_folder;
 }
 
-static gboolean
-get_model_iter (ModestFolderView *self, 
-               GtkTreeModel **model, 
-               GtkTreeIter *iter)
-{
-       GtkTreeModel *model_sort;
-       GtkTreeIter iter_sort;
-       GtkTreePath *path;
-       ModestFolderViewPrivate *priv;
-
-       priv = MODEST_FOLDER_VIEW_GET_PRIVATE(self);
-
-       if (!priv->cur_folder)
-               return FALSE;
-
-       if (!gtk_tree_row_reference_valid (priv->cur_row))
-               return FALSE;
-
-       model_sort = gtk_tree_view_get_model (GTK_TREE_VIEW (self));
-       *model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model_sort));
-
-       /* Get path to retrieve iter */
-       path = gtk_tree_row_reference_get_path (priv->cur_row);
-       if (!gtk_tree_model_get_iter (model_sort, &iter_sort, path))
-               return FALSE;
-
-       gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model_sort),
-                                                       iter,
-                                                       &iter_sort);
-       return TRUE;
-}
+/* static gboolean */
+/* get_model_iter (ModestFolderView *self,  */
+/*             GtkTreeModel **model,  */
+/*             GtkTreeIter *iter) */
+/* { */
+/*     GtkTreeModel *model_sort; */
+/*     GtkTreeIter iter_sort; */
+/*     GtkTreePath *path; */
+/*     ModestFolderViewPrivate *priv; */
+
+/*     priv = MODEST_FOLDER_VIEW_GET_PRIVATE(self); */
+
+/*     if (!priv->cur_folder) */
+/*             return FALSE; */
+
+/*     if (!gtk_tree_row_reference_valid (priv->cur_row)) */
+/*             return FALSE; */
+
+/*     model_sort = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); */
+/*     *model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model_sort)); */
+
+/*     /\* Get path to retrieve iter *\/ */
+/*     path = gtk_tree_row_reference_get_path (priv->cur_row); */
+/*     if (!gtk_tree_model_get_iter (model_sort, &iter_sort, path)) */
+/*             return FALSE; */
+
+/*     gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model_sort), */
+/*                                                     iter, */
+/*                                                     &iter_sort); */
+/*     return TRUE; */
+/* } */
 
 static gint
 cmp_rows (GtkTreeModel *tree_model, GtkTreeIter *iter1, GtkTreeIter *iter2,