Closed Bug 383938 Opened 17 years ago Closed 17 years ago

Unable to close account settings dialog

Categories

(SeaMonkey :: MailNews: Account Configuration, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ajschult784, Assigned: ajschult784)

References

Details

(Keywords: regression)

Attachments

(2 files)

Attached file javascript stack
When I try to close the account settings dialog after selecting the Local Folders account with current SeaMonkey trunk, I get the exception:

Error: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIMsgAccount.defaultIdentity]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://messenger/content/AccountManager.js :: saveAccount :: line 563"  data: no]
Source File: chrome://messenger/content/AccountManager.js
Line: 563

I've attached the javascript stack.  .defaultIdentity fails because
m_identities is empty (mCount=0 according to gdb), which is reasonable given that my prefs.js lists no identities for the Local Folders account.

http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/mailnews/base/src/nsMsgAccount.cpp&rev=1.81&mark=255#241

This regressed between 2007-06-06-11-trunk and 2007-06-07-11-trunk, which would finger bug 379070, although I haven't tracked down how it could be related.
Same here.
OS: Linux → All
Same here - with WinXP.
Looks like the checkin for bug 383485 that caused this, new code does not seem to cope with accounts with no default identity.
Attached patch patchSplinter Review
just return null if there are no identities
Attachment #267889 - Flags: superreview?(mscott)
Attachment #267889 - Flags: review?(mscott)
Assignee: mail → ajschult
Is it better to return NS_OK in nsMsgAccount::GetDefaultIdentity even if identity is null after calling do_QueryElementAt? 

-  nsCOMPtr<nsIMsgIdentity> identity( do_QueryElementAt(m_identities, 0));
+  nsCOMPtr<nsIMsgIdentity> identity( do_QueryElementAt(m_identities, 0, &rv));
   identity.swap(*aDefaultIdentity);
   return rv;
 }

would become:

+  nsCOMPtr<nsIMsgIdentity> identity( do_QueryElementAt(m_identities, 0));
   identity.swap(*aDefaultIdentity);
   return NS_OK;
 }

I'm trying to think what best matches the behavior of the code before Bug 379070.
Right.  I was avoiding that because
1. I wasn't sure what other possible reasons do_QueryElementAt might return failure (or might return failure in the future).  Currently, it would only return failure if m_identities is null (it isn't) or the array isn't long enough (which is the case we care about).
2. I didn't want to depend on the rest of the code doing something sane in the case of failure (it seems to).

The code I attached seems more robust.  It should match behavior of the code before Bug 379070, but without depending on do_QueryElementAt's behavior when m_identities is empty.
Comment on attachment 267889 [details] [diff] [review]
patch

cool. Thanks for the patch!
Attachment #267889 - Flags: superreview?(mscott)
Attachment #267889 - Flags: superreview+
Attachment #267889 - Flags: review?(mscott)
Attachment #267889 - Flags: review+
FIXED
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: