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

RESOLVED FIXED in Thunderbird 55.0


MailNews Core
a year ago
a year ago


(Reporter: aceman, Assigned: aceman)


Thunderbird 55.0

Firefox Tracking Flags

(Not tracked)




(1 attachment)

5.51 KB, patch
Jorg K (GMT+1)
: review+
Details | Diff | Splinter Review


a year 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);

Comment 1

a year 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)

Comment 3

a year ago
Created attachment 8845179 [details] [diff] [review]

OK, thanks.
In that case, I'll only convert some of the safe ones.
Try run:
Attachment #8845179 - Flags: review?(jorgk)

Comment 4

a year 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

a year ago
I can see 46 times |QueryInterface(NS_GET_IID(|.

Comment 6

a year 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?

Comment 7

a year 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

a year ago
Comment on attachment 8845179 [details] [diff] [review]

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

Comment 9

a year ago
Keywords: checkin-needed

Comment 10

a year ago
Last Resolved: a year 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.