use GetNextFile when iterating nsIDirectoryEnumerator in c-c

RESOLVED FIXED in Thunderbird 64.0

Status

enhancement
RESOLVED FIXED
10 months ago
9 months ago

People

(Reporter: aceman, Assigned: aceman)

Tracking

Trunk
Thunderbird 64.0

Firefox Tracking Flags

(Not tracked)

Details

()

Attachments

(1 attachment)

nsIFile->GetDirectoryEntries() returns a nsIDirectoryEnumerator, which has a GetNextFile() that returns a nsIFile directly.

See e.g.
https://dxr.mozilla.org/comm-central/source/modules/libpref/Preferences.cpp#4638

Try to use this in c-c instead of the older dance via GetNext(nsISupports) and then QIing to a nsIFile:

while (NS_SUCCEEDED(rv) && NS_SUCCEEDED(children->HasMoreElements(&hasMore)) && hasMore) {
      nsCOMPtr<nsISupports> supports;
      rv = children->GetNext(getter_AddRefs(supports));
      NS_ENSURE_SUCCESS(rv, rv);
      nsCOMPtr<nsIFile> childFile = do_QueryInterface(supports, &rv);
      NS_ENSURE_SUCCESS(rv, rv);
}
Comment on attachment 9014988 [details] [diff] [review]
1496727.patch

Wow, so much ugly code removed. And you wanted me to do a spot fix in bug 1496598 ;-) - Sadly your try run doesn't include Xpcshell tests, so that's were we would expect failures. Here's a new one:
https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=c89c1e5e592e5de6f26bc632a3dd4e05e524c3c2
Attachment #9014988 - Flags: review?(jorgk) → review+
I don't think removing old crusty code and following the same pattern everywhere is trivial ;-)
Severity: trivial → normal
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/a87795783553
use GetNextFile when iterating nsIDirectoryEnumerator in C-C. r=jorgk
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 64.0
You need to log in before you can comment on or make changes to this bug.