Avoid a crash on requesting to open a msg view that window mgr rejects.
[modest] / src / hildon2 / modest-msg-view-window.c
index 3b96231..cf2f3f3 100644 (file)
@@ -557,7 +557,6 @@ init_window (ModestMsgViewWindow *obj)
                      "hovershoot-max", 0,
                      NULL);
        gtk_container_add (GTK_CONTAINER (priv->main_scroll), priv->msg_view);
-       g_object_ref (priv->msg_view);
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->main_scroll, TRUE, TRUE, 0);
        gtk_container_add   (GTK_CONTAINER(obj), main_vbox);
 
@@ -637,7 +636,6 @@ modest_msg_view_window_finalize (GObject *obj)
        /* Sanity check: shouldn't be needed, the window mgr should
           call this function before */
        modest_msg_view_window_disconnect_signals (MODEST_WINDOW (obj));
-       g_object_unref (priv->msg_view);
 
        if (priv->fetch_image_redraw_handler > 0) {
                g_source_remove (priv->fetch_image_redraw_handler);
@@ -2211,10 +2209,10 @@ view_msg_cb (ModestMailOperation *mail_op,
        modest_window_mgr_unregister_header (modest_runtime_get_window_mgr (), header);
 
        row_reference = (GtkTreeRowReference *) user_data;
-       if (canceled) {
+       self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op);
+       if (canceled || !self || MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self)->msg_view == NULL ) {
                if (row_reference)
                        gtk_tree_row_reference_free (row_reference);
-               self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op);
                if (self) {
                        /* Restore window title */
                        update_window_title (self);
@@ -2228,7 +2226,6 @@ view_msg_cb (ModestMailOperation *mail_op,
        if (!modest_ui_actions_msg_retrieval_check (mail_op, header, msg)) {
                if (row_reference)
                        gtk_tree_row_reference_free (row_reference);
-               self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op);
                if (self) {
                        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
                        /* First we check if the parent is a folder window */
@@ -2292,7 +2289,6 @@ view_msg_cb (ModestMailOperation *mail_op,
        }
 
        /* Get the window */ 
-       self = (ModestMsgViewWindow *) modest_mail_operation_get_source (mail_op);
        g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self));
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);