* Fixed a lot of reference leaks
authorSergio Villar Senin <svillar@igalia.com>
Wed, 20 Jun 2007 09:45:50 +0000 (09:45 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 20 Jun 2007 09:45:50 +0000 (09:45 +0000)
* Fixed a problem when closing the main window

pmo-trunk-r2328

src/maemo/modest-main-window.c
src/maemo/modest-msg-view-window.c
src/maemo/modest-platform.c
src/modest-ui-actions.c
src/widgets/modest-folder-view.c
src/widgets/modest-header-view.c

index 5be7081..438adde 100644 (file)
@@ -746,22 +746,6 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        }
 }
 
-/* Debugging */
-/* static void  */
-/* on_window_destroy (ModestWindow *window,  */
-/*                ModestWindowMgr *self) */
-/* { */
-/*     ModestMainWindow *mw = NULL;     */
-/*     ModestMainWindowPrivate *priv = NULL; */
-
-/*     mw  = MODEST_MAIN_WINDOW (window); */
-/*     priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self); */
-
-/*     g_print ("\tMW: %d\n", ((GObject*)mw)->ref_count); */
-/*     g_print ("\tHV: %d\n", ((GObject*)priv->header_view)->ref_count); */
-/*     g_print ("\tFV: %d\n", ((GObject*)priv->folder_view)->ref_count); */
-/* } */
-
 ModestWindow *
 modest_main_window_new (void)
 {
@@ -914,11 +898,6 @@ modest_main_window_new (void)
 
        restore_settings (MODEST_MAIN_WINDOW(self), FALSE);
 
-/*     { */
-/*             g_signal_connect (self, "destroy",  */
-/*                               G_CALLBACK (on_window_destroy), self); */
-/*     } */
-
        return MODEST_WINDOW(self);
 }
 
index 45bf9ff..4b1b4eb 100644 (file)
@@ -1183,6 +1183,9 @@ view_msg_cb (ModestMailOperation *mail_op,
        modest_msg_view_window_update_priority (self);
        update_window_title (MODEST_MSG_VIEW_WINDOW (self));
        modest_msg_view_grab_focus (MODEST_MSG_VIEW (priv->msg_view));
+
+       /* Free new references */
+       g_object_unref (self);
 }
 
 TnyFolderType
index 7142485..1d7d5ac 100644 (file)
@@ -928,30 +928,27 @@ modest_platform_get_global_settings_dialog ()
 void 
 modest_platform_on_new_msg (void)
 {
-       return; /* TODO: Reenable this later. I disabled it to avoid having one notification per email. */
-#ifndef MODEST_HILDON_VERSION_0
-       HildonNotification *not;
-
-       /* Create a new notification. FIXME put the right values, need
-          some more specs */
-       not = hildon_notification_new ("TODO: (new email) Summary",
-                                      "TODO: (new email) Description",
-                                      "qgn_contact_group_chat_invitation",
-                                      "system.note.dialog");
-
-       /* Play sound SR-SND-18. TODO: play the right file */
+/*     HildonNotification *not; */
+
+/*     /\* Create a new notification. FIXME put the right values, need */
+/*        some more specs *\/ */
+/*     not = hildon_notification_new ("TODO: (new email) Summary", */
+/*                                    "TODO: (new email) Description", */
+/*                                    "qgn_contact_group_chat_invitation", */
+/*                                    "system.note.dialog"); */
+
+/*     /\* Play sound SR-SND-18. TODO: play the right file *\/ */
 /*     hildon_notification_set_sound (not, "/usr/share/sounds/ui-new_email.wav"); */
 
-       /* Set the led pattern */
-       notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (not), "led-pattern", 3);
+/*     /\* Set the led pattern *\/ */
+/*     notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (not), "led-pattern", 3); */
 
-       /* Notify. We need to do this in an idle because this function
-          could be called from a thread */
-       if (!notify_notification_show (NOTIFY_NOTIFICATION (not), NULL))
-               g_error ("Failed to send notification");
+/*     /\* Notify. We need to do this in an idle because this function */
+/*        could be called from a thread *\/ */
+/*     if (!notify_notification_show (NOTIFY_NOTIFICATION (not), NULL)) */
+/*             g_error ("Failed to send notification"); */
                
-       g_object_unref (not);
-#endif /*MODEST_HILDON_VERSION_0*/
+/*     g_object_unref (not); */
 }
 
 
index c8f629e..e177ba1 100644 (file)
@@ -658,6 +658,7 @@ open_msg_cb (ModestMailOperation *mail_op,
 cleanup:
        /* Free */
        g_free(account);
+       g_object_unref (parent_win);
        g_object_unref (msg);
        g_object_unref (folder);
        g_object_unref (header);
@@ -679,6 +680,7 @@ modest_ui_actions_get_msgs_full_error_handler (ModestMailOperation *mail_op,
 
                modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
                                                        error->message);
+               g_object_unref (win);
        }
 }
 
@@ -1903,6 +1905,7 @@ modest_ui_actions_delete_folder_error_handler (ModestMailOperation *mail_op,
 
        modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
                                                _("mail_in_ui_folder_delete_error"));
+       g_object_unref (win);
 }
 
 static void
@@ -2789,6 +2792,7 @@ modest_ui_actions_move_folder_error_handler (ModestMailOperation *mail_op,
        /* TODO: show error message */
        modest_platform_run_information_dialog ((win) ? GTK_WINDOW (win) : NULL,
                                                _("mail_in_ui_folder_move_target_error"));
+       g_object_unref (win);
 }
 
 /*
index eec1b19..c4b85e6 100644 (file)
@@ -161,6 +161,8 @@ struct _ModestFolderViewPrivate {
        gchar                *local_account_name;
        gchar                *visible_account_id;
        ModestFolderViewStyle style;
+
+       gboolean              reselect; /* we use this to force a reselection of the INBOX */
 };
 #define MODEST_FOLDER_VIEW_GET_PRIVATE(o)                      \
        (G_TYPE_INSTANCE_GET_PRIVATE((o),                       \
@@ -493,6 +495,7 @@ modest_folder_view_init (ModestFolderView *obj)
        priv->clipboard = modest_runtime_get_email_clipboard ();
        priv->hidding_ids = NULL;
        priv->n_selected = 0;
+       priv->reselect = FALSE;
 
        /* Build treeview */
        add_columns (GTK_WIDGET (obj));
@@ -690,6 +693,24 @@ modest_folder_view_set_title (ModestFolderView *self, const gchar *title)
                                           title != NULL);
 }
 
+static gboolean
+modest_folder_view_on_map (ModestFolderView *self, 
+                          GdkEventExpose *event,
+                          gpointer data)
+{
+       ModestFolderViewPrivate *priv;
+
+       priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
+
+       /* This won't happen often */
+       if (G_UNLIKELY (priv->reselect)) {
+               /* Select the first inbox or the local account if not found */
+               modest_folder_view_select_first_inbox_or_local (self);
+               priv->reselect = FALSE;
+       }
+       return FALSE;
+}
+
 GtkWidget*
 modest_folder_view_new (TnyFolderStoreQuery *query)
 {
@@ -707,6 +728,8 @@ modest_folder_view_new (TnyFolderStoreQuery *query)
        priv->changed_signal = g_signal_connect (sel, "changed",
                                                 G_CALLBACK (on_selection_changed), self);
 
+       g_signal_connect (self, "expose-event", G_CALLBACK (modest_folder_view_on_map), NULL);
+
        return GTK_WIDGET(self);
 }
 
@@ -862,18 +885,16 @@ modest_folder_view_update_model (ModestFolderView *self,
        gtk_tree_view_set_model (GTK_TREE_VIEW(self), filter_model);
 /*     gtk_tree_view_set_model (GTK_TREE_VIEW(self),  */
 /*                              (filter_model) ? filter_model : sortable); */
-       expand_root_items (self); /* expand all account folders */
-       
+
        g_object_unref (model);
-       
        g_object_unref (filter_model);
 /*     if (filter_model) */
 /*             g_object_unref (filter_model); */
                        
        g_object_unref (sortable);
 
-       /* Select the first inbox or the local account if not found */
-       modest_folder_view_select_first_inbox_or_local (self);
+       /* Force a reselection of the INBOX next time the widget is shown */
+       priv->reselect = TRUE;
                        
        return TRUE;
 }
index a4b3510..e8d2a89 100644 (file)
@@ -525,8 +525,6 @@ modest_header_view_dispose (GObject *obj)
        G_OBJECT_CLASS(parent_class)->dispose (obj);
 }
 
-
-
 static void
 modest_header_view_finalize (GObject *obj)
 {
@@ -969,7 +967,6 @@ modest_header_view_set_folder (ModestHeaderView *self,
                g_mutex_lock (priv->observers_lock);
                tny_folder_remove_observer (priv->folder, TNY_FOLDER_OBSERVER (self));
                g_object_unref (priv->folder);
-/*             g_print ("---------- REMAINING %d\n", ((GObject*)priv->folder)->ref_count); */
                priv->folder = NULL;
                g_mutex_unlock (priv->observers_lock);
        }