jojobear99 / PopTrayU

Bug Tracking Repository for open source project PopTrayU
GNU General Public License v2.0
0 stars 0 forks source link

POP deleting only every other message #36

Open jojobear99 opened 8 years ago

jojobear99 commented 8 years ago

Moodolf reports

Oh and deletion of messages on POP3 accounts does not work as it should. I mark messages as "delete" and when I press "Check" it should delete EVERY marked messeage, but it will only delete every second message. 8 msgs marked to delete -> "check" -> 4 msgs marked -> "check" -> 2 msgs marked -> "check" -> 1 msg marked -> "check" -> 0 msg.

Vort commented 7 years ago

This happens because of incorrect removal loop in TMailItems.RemoveDeletedMessages and similar procedures. Bug can be perfectly reproduced on localhost with JES server. My knowledge of Delphi is bad, but looks like this rewrite can help:

Index: source/uMailItems.pas
===================================================================
--- source/uMailItems.pas   (revision 925)
+++ source/uMailItems.pas   (working copy)
@@ -247,14 +247,14 @@
 // all messages no longer on the server
 // @Return - True if messages were removed, false if no changes
 var
-  mailItem : TMailItem;
+  i : Integer;
 begin
   Result := False;
-  for mailItem in Self do
+  for i := Pred(Count) downto 0 do
   begin
-    if mailItem.MsgNum = -1 then
+    if Self[i].MsgNum = -1 then
     begin
-      Remove(mailItem);
+      Delete(i);
       Result := True;
     end
   end;
jojobear99 commented 6 years ago

Thank you! :)