Commits

Thomas Roessler  committed 0bf893c

When replying to a message/rfc822 attachment, the Context statistics
would get out of order. Problem noted by Johan van Selst
<johans@stack.nl>.

  • Participants
  • Parent commits 5ca8e36
  • Branches HEAD

Comments (0)

Files changed (3)

 #include "sort.h"
 #include "mx.h"
 
-void mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf)
+void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
 {
   int changed = h->changed;
   int deleted = ctx->deleted;
 	if (!h->deleted)
 	{
 	  h->deleted = 1;
-	  ctx->deleted++;
+	  if (upd_ctx) ctx->deleted++;
 	}
       }
       else if (h->deleted)
       {
 	h->deleted = 0;
-	ctx->deleted--;
+	if (upd_ctx) ctx->deleted--;
 #ifdef USE_IMAP
 /* if you undelete a message, the imap server will probably need to know. */
 	if (ctx->magic == M_IMAP) 
 	{
 	  h->changed = 1;
-	  ctx->changed = 1;
+	  if (upd_ctx) ctx->changed = 1;
 	}
 #endif
       }
 	if (h->read || h->old)
 	{
 	  h->old = 0;
-	  ctx->new++;
+	  if (upd_ctx) ctx->new++;
 	  if (h->read)
 	  {
 	    h->read = 0;
-	    ctx->unread++;
+	    if (upd_ctx) ctx->unread++;
 	  }
 	  h->changed = 1;
-	  ctx->changed = 1;
+	  if (upd_ctx) ctx->changed = 1;
 	}
       }
       else if (!h->read)
       {
 	if (!h->old)
-	  ctx->new--;
+	  if (upd_ctx) ctx->new--;
 	h->read = 1;
-	ctx->unread--;
+	if (upd_ctx) ctx->unread--;
 	h->changed = 1;
-	ctx->changed = 1;
+	if (upd_ctx) ctx->changed = 1;
       }
       break;
 
 	{
 	  h->old = 1;
 	  if (!h->read)
-	    ctx->new--;
+	    if (upd_ctx) ctx->new--;
 	  h->changed = 1;
-	  ctx->changed = 1;
+	  if (upd_ctx) ctx->changed = 1;
 	}
       }
       else if (h->old)
       {
 	h->old = 0;
 	if (!h->read)
-	  ctx->new++;
+	  if (upd_ctx) ctx->new++;
 	h->changed = 1;
-	ctx->changed = 1;
+	if (upd_ctx) ctx->changed = 1;
       }
       break;
 
 	if (!h->read)
 	{
 	  h->read = 1;
-	  ctx->unread--;
+	  if (upd_ctx) ctx->unread--;
 	  if (!h->old)
-	    ctx->new--;
+	    if (upd_ctx) ctx->new--;
 	  h->changed = 1;
-	  ctx->changed = 1;
+	  if (upd_ctx) ctx->changed = 1;
 	}
       }
       else if (h->read)
       {
 	h->read = 0;
-	ctx->unread++;
+	if (upd_ctx) ctx->unread++;
 	if (!h->old)
-	  ctx->new++;
+	  if (upd_ctx) ctx->new++;
 	h->changed = 1;
-	ctx->changed = 1;
+	if (upd_ctx) ctx->changed = 1;
       }
       break;
 
 	  if (!h->read)
 	  {
 	    h->read = 1;
-	    ctx->unread--;
+	    if (upd_ctx) ctx->unread--;
 	    if (!h->old)
-	      ctx->new--;
+	      if (upd_ctx) ctx->new--;
 	  }
 	  h->changed = 1;
-	  ctx->changed = 1;
+	  if (upd_ctx) ctx->changed = 1;
 	}
       }
       else if (h->replied)
       {
 	h->replied = 0;
 	h->changed = 1;
-	ctx->changed = 1;
+	if (upd_ctx) ctx->changed = 1;
       }
       break;
 
 	if (!h->flagged)
 	{
 	  h->flagged = bf;
-	  ctx->flagged++;
+	  if (upd_ctx) ctx->flagged++;
 	  h->changed = 1;
-	  ctx->changed = 1;
+	  if (upd_ctx) ctx->changed = 1;
 	}
       }
       else if (h->flagged)
       {
 	h->flagged = 0;
-	ctx->flagged--;
+	if (upd_ctx) ctx->flagged--;
 	h->changed = 1;
-	ctx->changed = 1;
+	if (upd_ctx) ctx->changed = 1;
       }
       break;
 
 	if (!h->tagged)
 	{
 	  h->tagged = 1;
-	  ctx->tagged++;
+	  if (upd_ctx) ctx->tagged++;
 	}
       }
       else if (h->tagged)
       {
 	h->tagged = 0;
-	ctx->tagged--;
+	if (upd_ctx) ctx->tagged--;
       }
       break;
   }
 #define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,0,NULL,NULL)
 void _mutt_select_file (char *, size_t, int, int, char ***, int *);
 void mutt_send_hook (HEADER *);
-void mutt_set_flag (CONTEXT *, HEADER *, int, int);
+void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
+#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)
 void mutt_set_followup_to (ENVELOPE *);
 void mutt_set_body_charset (BODY *, const char *);
 void mutt_shell_escape (void);

File recvattach.c

   if (!tag && body->hdr)
   {
     hn = body->hdr;
-    hn->msgno = hdr->msgno; /* required for MH/maildir */
+    hn->msgno   = hdr->msgno; /* required for MH/maildir */
+    hn->replied = hdr->replied;
+    hn->read    = hdr->read;
+    hn->old	= hdr->old;
+    hn->changed = hdr->changed;
     ctx = Context;
   }
   else
   else
     ci_send_message (op, NULL, NULL, ctx, hn);
 
-  if (hn->replied && !hdr->replied)
-    mutt_set_flag (Context, hdr, M_REPLIED, 1);
+  if (hn->replied)
+  {
+    if (Context != ctx)
+      mutt_set_flag (Context, hdr, M_REPLIED, 1);
+    else
+      _mutt_set_flag (Context, hdr, M_REPLIED, 1, 0);
+  }
 
 cleanup: