remove some small occurrences of nsISupportsArray in mailnews

RESOLVED FIXED in Thunderbird 23.0

Status

MailNews Core
Backend
--
minor
RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: aceman, Assigned: aceman)

Tracking

Trunk
Thunderbird 23.0
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 6 obsolete attachments)

19.35 KB, patch
aceman
: review+
Details | Diff | Splinter Review
(Assignee)

Description

5 years ago
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.
(Assignee)

Updated

5 years ago
Status: NEW → ASSIGNED
Summary: remove some occurrences of nsISupportsArray in mailnews → remove some small occurrences of nsISupportsArray in mailnews
(Assignee)

Comment 1

5 years ago
Created attachment 710940 [details] [diff] [review]
WIP patch

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 2

5 years ago
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+
(Assignee)

Updated

5 years ago
Depends on: 833988
(Assignee)

Comment 3

5 years ago
Created attachment 711570 [details] [diff] [review]
patch v2
Attachment #710940 - Attachment is obsolete: true
Attachment #711570 - Flags: review?(neil)

Comment 4

5 years ago
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.]
(Assignee)

Comment 5

5 years ago
Created attachment 729285 [details] [diff] [review]
patch v3
Attachment #711570 - Attachment is obsolete: true
Attachment #711570 - Flags: review?(neil)
Attachment #729285 - Flags: review?(neil)

Comment 6

4 years ago
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-
(Assignee)

Comment 7

4 years ago
Created attachment 729826 [details] [diff] [review]
patch v4
Attachment #729285 - Attachment is obsolete: true
Attachment #729826 - Flags: review?(neil)

Comment 8

4 years ago
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.)
(Assignee)

Comment 9

4 years ago
Sorry, what a thinko :)

Why should I keep 'child'? I tried to reuse the existing variable 'item'.
(Assignee)

Comment 10

4 years ago
Created attachment 730287 [details] [diff] [review]
patch v5
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.
(Assignee)

Comment 12

4 years ago
OK, I merged child and item and moved the new declaration above them so it can be shared. So what to do now?
(Assignee)

Comment 13

4 years ago
Created attachment 731369 [details] [diff] [review]
patch v6
Attachment #730287 - Attachment is obsolete: true
Attachment #730287 - Flags: review?(neil)
Attachment #731369 - Flags: review?(neil)
(Assignee)

Comment 14

4 years ago
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)
(Assignee)

Comment 16

4 years ago
(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.
(Assignee)

Comment 17

4 years ago
Created attachment 732898 [details] [diff] [review]
patch v7

Fixed the hasMore variable name.
Attachment #731369 - Attachment is obsolete: true
Attachment #732898 - Flags: review+
(Assignee)

Updated

4 years ago
Keywords: checkin-needed
https://hg.mozilla.org/comm-central/rev/fbc1cf677a5c
Status: ASSIGNED → RESOLVED
Last Resolved: 4 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.