convert some QueryInterface(NS_GET_IID(), ) occurrences to do_QueryInterface() in mailnews

RESOLVED FIXED in Thunderbird 55.0

Status

defect
--
trivial
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: aceman, Assigned: aceman)

Tracking

Trunk
Thunderbird 55.0
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

()

Attachments

(1 attachment)

Assignee

Description

2 years ago
+++ This bug was initially created as a clone of Bug #1340845 comment 5+++

Convert some QueryInterface(NS_GET_IID(), ) occurrences to do_QueryInterface() in mailnews C++ code. The new helper is shorter and retrieves the interface class automatically. It fails compilation if the interface is ambiguous (there are multiple interfaces possible to be queried).

The pattern:
-  nsCOMPtr<nsINntpIncomingServer> nntpServer;
-  rv = server->QueryInterface(NS_GET_IID(nsINntpIncomingServer),
-                              getter_AddRefs(nntpServer));
+  nsCOMPtr<nsINntpIncomingServer> nntpServer = do_QueryInterface(server, &rv);
Assignee

Comment 1

2 years ago
I'm not sure about the case when there is QueryInterface(IID, (void**)result), instead of getterAddRefs(result). Are those also safe to convert?

Sadly, many of the occurrences found can't be converted as the queried interface can't be automatically inferred so the specification of IID is necessary.
Flags: needinfo?(rkent)
I'm not sure about that case, either. I've never fully understood do_QueryInterface.
Flags: needinfo?(rkent)
Assignee

Comment 3

2 years ago
Posted patch patchSplinter Review
OK, thanks.
In that case, I'll only convert some of the safe ones.
Try run: https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=b85251d734d55da14651082562f1be62cace8d46
Attachment #8845179 - Flags: review?(jorgk)

Comment 4

2 years ago
(In reply to :aceman from comment #3)
In that case, I'll only convert some of the safe ones.
Some? Can we do all the safe ones? How many are there, how many are safe?

Comment 5

2 years ago
I can see 46 times |QueryInterface(NS_GET_IID(|.

Comment 6

2 years ago
OK, I didn't look well enough. Some of the 46 are in return statements, so they can't be converted. I also tried to convert some more in nsImapMailFolder.cpp and failed. So have we exhausted the conversion possibilities?
Assignee

Comment 7

2 years ago
I haven't found any more to convert.
Many of those you see either are missing the getter_AddRefs we are not sure about or the removal of the NS_GET_IID() caused compile failure as somehow the automatic inference of the class fails and compiler complains about ambiguous conversion (as said in comment 1).

Comment 8

2 years ago
Comment on attachment 8845179 [details] [diff] [review]
patch

OK, let's take these then. I tried a few others with no success.
Attachment #8845179 - Flags: review?(jorgk) → review+
Assignee

Comment 9

2 years ago
Thanks.
Keywords: checkin-needed

Comment 10

2 years ago
https://hg.mozilla.org/comm-central/rev/671537074650c774078be7374aa61145405099b8
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 55.0
You need to log in before you can comment on or make changes to this bug.