+++ 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);
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.
I'm not sure about that case, either. I've never fully understood do_QueryInterface.
Created attachment 8845179 [details] [diff] [review] patch 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)
(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?
I can see 46 times |QueryInterface(NS_GET_IID(|.
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?
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 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+
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 55.0
You need to log in before you can comment on or make changes to this bug.