Closed Bug 823819 Opened 12 years ago Closed 12 years ago

Deleting all messages from folder generates errors

Categories

(SeaMonkey :: MailNews: Message Display, defect)

defect
Not set
normal

Tracking

(seamonkey2.17 fixed)

RESOLVED FIXED
seamonkey2.17
Tracking Status
seamonkey2.17 --- fixed

People

(Reporter: ewong, Assigned: iannbugzilla)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

      No description provided.
Errors:

rror: An error occurred updating the cmd_delete command: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIMsgDBView.hdrForFirstSelectedMessage]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: chrome://messenger/content/folderDisplay.js :: gFolderDisplay.selectedMessage :: line 18"  data: no]
Source file: chrome://global/content/globalOverlay.js
Line: 81
 ----------
Wed Dec 19 2012 22:05:38
Error: An error occurred updating the button_junk command: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIMsgDBView.hdrForFirstSelectedMessage]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: chrome://messenger/content/folderDisplay.js :: gFolderDisplay.selectedMessage :: line 18"  data: no]
Source file: chrome://global/content/globalOverlay.js
Line: 81
 ----------
Wed Dec 19 2012 22:05:38
Error: An error occurred updating the button_delete command: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIMsgDBView.hdrForFirstSelectedMessage]"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: chrome://messenger/content/folderDisplay.js :: gFolderDisplay.selectedMessage :: line 18"  data: no]
Source file: chrome://global/content/globalOverlay.js
Line: 81

bisecting gives the following possible pushes:

 http://hg.mozilla.org/comm-central/rev/c7bf9a085fc4
or
 http://hg.mozilla.org/comm-central/rev/b849a17c4bc1

CC'ing IanN as these are his pushes and maybe can shed a light as to
what's going on.
OS: Windows Vista → All
Steps to Reproduce:

1) Open Mail & News
2) If you have mail in Inbox, delete them all via <select all> Delete.
3) In Error console, the errors appear.
I've zeroed in on the cset that's causing the errors.

It's http://hg.mozilla.org/comm-central/rev/b849a17c4bc1.
With further tests, reverting the following changes makes the
errors disappear:

http://hg.mozilla.org/comm-central/rev/b849a17c4bc1#l2.110->2.118

and 

http://hg.mozilla.org/comm-central/rev/b849a17c4bc1#l2.88->2.101
Addendum.

It seems as if there's an assumption in the previous code 
(i.e:
function SelectedMessagesAreDeleted()
{
  if (!gDBView || !gDBView.numSelected)
    return false;

  try
  {
    return gDBView.hdrForFirstSelectedMessage.flags &
           Components.interfaces.nsMsgMessageFlags.IMAPDeleted;
  }
  catch (ex)
  {
    // hdrForFirstSelectedMessage found an empty or invalid selection
    // even though numSelected indicated otherwise
    return false;
  }
}

When you delete all the messages, it fails in the try and catches the
exception and returns false.   For some reasons, it doesn't like
gDBView.hdrForFirstSelectedMessage.   Ditto with:


function SelectedMessagesAreJunk()
{
  var isJunk;
  try {
      var junkScore = gDBView.hdrForFirstSelectedMessage.getStringProperty("junkscore");
      isJunk =  ((junkScore != "") && (junkScore != "0"));
  }
  catch (ex) {
      isJunk = false;
  }
  return isJunk;
}

It just doesn't like accessing gDBView.hdrForFirstSelectedMessage for
this particular code pathway.  (Delete message, and I'm assuming Junk
message).  So IanN's patch actually exposes the 'badness' of the assumption
that even though gDBView isn't null, gDBView.hdrForFirstSelectedMessage
is a valid call.  And apparently it isn't a valid call for this set
of condtions(steps).
(In reply to Edmund Wong (:ewong) from comment #5)
> Addendum.
> 
> It seems as if there's an assumption in the previous code 

The 'assumption' being that the 'try' part succeeds, when it
doesn't.
Using selectedIndices.length seems to be more reliable than selectedCount.
Alternatively could just make selectedCount return selectedIndices.length
Ideally gDBView.numSelected should be fixed but I don't know that code.
Assignee: nobody → iann_bugzilla
Status: NEW → ASSIGNED
Attachment #695325 - Flags: review?(neil)
Attachment #695325 - Flags: feedback?(ewong)
Comment on attachment 695325 [details] [diff] [review]
Fix selectedMessage/selectedMessageUri [Checked in: Comment 10]

Works like a charm with the patch.
Attachment #695325 - Flags: feedback?(ewong) → feedback+
Blocks: 824429
Comment on attachment 695325 [details] [diff] [review]
Fix selectedMessage/selectedMessageUri [Checked in: Comment 10]

The problem with using this.selectedIndices is that it involves copying an array from C++ to JavaScript, while selectedCount is just an integer, so I'd prefer something that avoided calling selectedIndices except in the case where it might disagree with selectedCount.
Attachment #695325 - Flags: review?(neil) → review+
Hardware: x86 → All
Version: SeaMonkey 2.15 Branch → Trunk
Summary: Deleting all messages from folder generates errors: → Deleting all messages from folder generates errors
Comment on attachment 695325 [details] [diff] [review]
Fix selectedMessage/selectedMessageUri [Checked in: Comment 10]

http://hg.mozilla.org/comm-central/rev/30a6d21a5ec2
Attachment #695325 - Attachment description: Fix selectedMessage/selectedMessageUri → Fix selectedMessage/selectedMessageUri [Checked in: Comment 10]
Target Milestone: --- → seamonkey2.17
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Blocks: 825865
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: