Closed Bug 1846860 Opened 2 years ago Closed 2 years ago

nsMsgDBFolder.mNumUnreadMessages can get out-of-date calling MarkMessagesRead

Categories

(MailNews Core :: General, defect)

defect

Tracking

(thunderbird_esr102 wontfix, thunderbird_esr115 fixed, thunderbird117 fixed)

RESOLVED FIXED
118 Branch
Tracking Status
thunderbird_esr102 --- wontfix
thunderbird_esr115 --- fixed
thunderbird117 --- fixed

People

(Reporter: darktrojan, Assigned: darktrojan)

References

Details

Attachments

(1 file)

Usually when calling nsMsgDBFolder::MarkMessagesRead the count of unread messages mNumUnreadMessages is updated via

  • nsMsgHdr::MarkRead
  • nsMsgDatabase::MarkRead
  • nsMsgDatabase::MarkHdrRead
  • nsMsgDatabase::MarkHdrReadInDB
  • nsMsgDBFolder::OnHdrFlagsChanged
  • nsMsgDBFolder::UpdateSummaryTotals

but in some cases OnHdrFlagsChanged doesn't get called. I assume that for some reason we've stopped listening to database notifications.

This could explain a lot of weirdness, quite likely including bug 1833345. I have a test that fails every time, which is how I figured out what's happening. (Not the first time I've run into this problem while writing tests, I'm sure.) I'll try to reduce it to the minimum required to show the bug, then figure out the best fix. If nothing else works we can just call UpdateSummaryTotals at the end of MarkMessagesRead, which is essentially a no-op if it has already been called.

I ranted about null msgDatabase issues in Bug 1795178. Basically, I think msgDatabase should be a read-only attr, and never null (even if the database file is closed).
But I think it'd be a lot of work to understand the mork/nsMsgDatabase code well enough to make that change, so for now we limp along adding bandaids like this one until we do a more substantial overhaul of database stuff.

See Also: → 1795178, 1760925
Target Milestone: --- → 118 Branch

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/8058f3a4ecdc
Restore folder database before marking messages as read or flagged. r=BenC

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

Comment on attachment 9347057 [details]
Bug 1846860 - Restore folder database before marking messages as read or flagged. r=BenC

[Triage Comment]
Approved for beta

Attachment #9347057 - Flags: approval-comm-beta+

Comment on attachment 9347057 [details]
Bug 1846860 - Restore folder database before marking messages as read or flagged. r=BenC

[Approval Request Comment]
Regression caused by (bug #): ancient history
User impact if declined: unread message counts can be wrong
Testing completed (on c-c, etc.): in beta 2
Risk to taking this patch (and alternatives if risky): no

Attachment #9347057 - Flags: approval-comm-esr115?
Blocks: 1845011

Comment on attachment 9347057 [details]
Bug 1846860 - Restore folder database before marking messages as read or flagged. r=BenC

[Triage Comment]
Approved for esr115

Attachment #9347057 - Flags: approval-comm-esr115? → approval-comm-esr115+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: