I'm sorry this section is in the way for first-time readers. You may want to skip directly to the Getting Started Guide, the Reference Manual, or the FAQ. I put this section at the top so that checking for recent changes will be easy.
Recent changes to
Most recent first
nsCOMPtrand a raw pointer (or a literal
nsnull) work correctly on all compilers. See bug 65664.
getter_AddRefs( nsCOMPtr& )apply the same type-safety check that the simple assignment forms do.
- Eliminated the need to cast
- Relaxed the invariant for
nsCOMPtr<nsISupports>, so that it is now a pointer to any XPCOM interface.
do_QueryReferentto make using
- bug 59212: as soon as we test on more compilers, start recommending
already_AddRefedas a function result.
- bug 59414: making
privatemay help prevent some leaks caused by casting
- Move the factored
nsCOMPtrroutines into their own library, to reduce
nsCOMPtrclients' dependency on the XPCOM library.
Recent changes to this document
- Removed the statement that
nsCOMPtrand a raw pointer or literal 0 does not work on some compilers since it is no longer true.
- Added an entire section to the Getting Started Guide on
nsCOMPtrs in function signatures
- Added references to recent bugs influencing the use of
nsCOMPtrmachinery: bug 59212, and bug 59414
- Fixed comparisons 1 and 3, as per comments by Morten Welinder
- Updated examples to prefer direct initialization over copy initialization.