* src/widgets/modest-window-mgr.c:
[modest] / src / modest-mail-operation-queue.c
index 600438b..53cd086 100644 (file)
@@ -316,6 +316,7 @@ modest_mail_operation_queue_cancel (ModestMailOperationQueue *self,
 static void
 on_cancel_all_foreach (gpointer op, gpointer list)
 {
+       g_return_if_fail (list);
        *((GSList**)list) = g_slist_prepend (*((GSList**)list), MODEST_MAIL_OPERATION (op));
 }
 
@@ -323,8 +324,8 @@ void
 modest_mail_operation_queue_cancel_all (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
-       GSList* operations_to_cancel;
-       GSList* cur;
+       GSList* operations_to_cancel = NULL;
+       GSList* cur = NULL;
 
        g_return_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self));
 
@@ -338,13 +339,16 @@ modest_mail_operation_queue_cancel_all (ModestMailOperationQueue *self)
        g_mutex_lock (priv->queue_lock);
        g_queue_foreach (priv->op_queue, (GFunc) on_cancel_all_foreach, &operations_to_cancel);
        g_mutex_unlock (priv->queue_lock);
-
+       
        /* TODO: Reverse the list, to remove operations in order? */
 
        for(cur = operations_to_cancel; cur != NULL; cur = cur->next) {
                /* This triggers a progress_changed signal in which we remove
                 * the operation from the queue. */
-               modest_mail_operation_cancel (MODEST_MAIL_OPERATION (cur->data));
+               if (!MODEST_IS_MAIL_OPERATION(cur->data))
+                       g_printerr ("modest: cur->data is not a valid mail operation\n");
+               else
+                       modest_mail_operation_cancel (MODEST_MAIL_OPERATION (cur->data));
        }
 
        g_slist_free(operations_to_cancel);