Closed Bug 838805 Opened 9 years ago Closed 9 years ago

remove some small occurrences of nsISupportsArray in mailnews

Categories

(MailNews Core :: Backend, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 23.0

People

(Reporter: aceman, Assigned: aceman)

References

Details

Attachments

(1 file, 6 obsolete files)

Convert these to nsCOMArray (or something else):
mailnews/local/src/nsLocalMailFolder.cpp::mDownloadMessages
mailnews/base/src/nsMsgSearchDBView.cpp::m_hdrsForEachFolder

Remove now unneeded 'interface nsISupportsArray;' from nsIMsgFolder.idl.
Some files inherited the definitions without including nsISupportsArray.h so I add them where needed now.
Status: NEW → ASSIGNED
Summary: remove some occurrences of nsISupportsArray in mailnews → remove some small occurrences of nsISupportsArray in mailnews
Attached patch WIP patch (obsolete) — Splinter Review
I am not sure what the nsISupportsArray.clone() usages were supposed to do and if the conversion to AppendElements is enough for them.
Attachment #710940 - Flags: feedback?(neil)
Comment on attachment 710940 [details] [diff] [review]
WIP patch

>   newMsgDBView->m_folders.InsertObjectsAt(m_folders, 0);
m_folders is an nsCOMArray so you see how it works (although feel free to use AppendObjects/AppendElements instead).

>+  // ACE: is this still needed? There is no other use of m_copyListenerList...
I agree, it looks unused.
Attachment #710940 - Flags: feedback?(neil) → feedback+
Depends on: 833988
Attached patch patch v2 (obsolete) — Splinter Review
Attachment #710940 - Attachment is obsolete: true
Attachment #711570 - Flags: review?(neil)
Comment on attachment 711570 [details] [diff] [review]
patch v2

>   // now copy all of our private member data
>   newMsgDBView->mDestFolder = mDestFolder;
>   newMsgDBView->mCommand = mCommand;
>   newMsgDBView->mTotalIndices = mTotalIndices;
>   newMsgDBView->mCurIndex = mCurIndex; 
>   newMsgDBView->m_folders.InsertObjectsAt(m_folders, 0);
>   newMsgDBView->m_curCustomColumn = m_curCustomColumn;
> 
Nit: don't need this blank line any more.

>+  m_hdrsForEachFolder.InsertObjectsAt(newMsgDBView->m_hdrsForEachFolder, 0);
Still the wrong way around, compare m_folders above and m_uniqueFoldersSelected below!

> 
>   newMsgDBView->m_uniqueFoldersSelected.InsertObjectsAt(m_uniqueFoldersSelected, 0);
[The blank line here can probably go too.]

> nsMsgSearchDBView::GetFoldersAndHdrsForSelection(nsMsgViewIndex *indices, int32_t numIndices)
[Wow, this method is lame. It loops through all of the selected messages and establishes an array of unique folders. It then loops through the array again once for each folder, extracting those messages that are from that folder... After this lands, I might submit a rewrite.]
Attached patch patch v3 (obsolete) — Splinter Review
Attachment #711570 - Attachment is obsolete: true
Attachment #711570 - Flags: review?(neil)
Attachment #729285 - Flags: review?(neil)
Comment on attachment 729285 [details] [diff] [review]
patch v3

>-            nsCOMPtr<nsISupports> child;
>+            nsCOMPtr<nsIMsgFolder> child;
>             rv = enumerator->GetNext(getter_AddRefs(child));
I consider it a bug that this actually compiles :-( You need to GetNext into an nsISupports, then do_QueryInterface into the nsIMsgFolder.
Attachment #729285 - Flags: review?(neil) → review-
Attached patch patch v4 (obsolete) — Splinter Review
Attachment #729285 - Attachment is obsolete: true
Attachment #729826 - Flags: review?(neil)
Comment on attachment 729826 [details] [diff] [review]
patch v4

>-            nsCOMPtr<nsISupports> child;
>-            rv = enumerator->GetNext(getter_AddRefs(child));
>+            nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(item, &rv));
>+            rv = enumerator->GetNext(getter_AddRefs(folder));
Didn't I say GetNext comes first, then do_QueryInterface? (And you can keep the existing child variable.)
Sorry, what a thinko :)

Why should I keep 'child'? I tried to reuse the existing variable 'item'.
Attached patch patch v5 (obsolete) — Splinter Review
Attachment #729826 - Attachment is obsolete: true
Attachment #729826 - Flags: review?(neil)
Attachment #730287 - Flags: review?(neil)
(In reply to aceman from comment #9)
> Why should I keep 'child'? I tried to reuse the existing variable 'item'.

Depends on your point of view; 'child' looks like it's the existing variable compared to the code before the patch, but 'item' is "existing" compared to the code after the original patch.
OK, I merged child and item and moved the new declaration above them so it can be shared. So what to do now?
Attached patch patch v6 (obsolete) — Splinter Review
Attachment #730287 - Attachment is obsolete: true
Attachment #730287 - Flags: review?(neil)
Attachment #731369 - Flags: review?(neil)
Neil?
Flags: needinfo?(neil)
Comment on attachment 731369 [details] [diff] [review]
patch v6

[Sorry for the delay; bugmail backlog.]

I'm not entirely convinced about merging those two variables, as one is child folders while the other is messages and it might confuse someone later on.

The hasNext merger isn't so bad, but IMHO you should have kept the short name.
Attachment #731369 - Flags: review?(neil) → review+
Flags: needinfo?(neil)
(In reply to neil@parkwaycc.co.uk from comment #15)
> I'm not entirely convinced about merging those two variables, as one is
> child folders while the other is messages and it might confuse someone later
> on.

I merged it based on the variable type. Semantically, in this case of nsISupports, it is not a folder or a message (but a generic enumerator item) until you queryInterface it to one of those. And that object then has a separate variable with proper name.
Attached patch patch v7Splinter Review
Fixed the hasMore variable name.
Attachment #731369 - Attachment is obsolete: true
Attachment #732898 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/comm-central/rev/fbc1cf677a5c
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 23.0
You need to log in before you can comment on or make changes to this bug.