On 08/12/2014 10:06 AM, Ehsan Akhgari wrote: > It could also be solved with making operator T*() explicit, but neither of > these options are something that we can use in our code base today.
So at risk of adding yet another flavor of thing: why not introduce an already_AddRefed<T> sort of struct that *does* own an addref, *will* release on destruction if not nulled out, and does *not* explicitly convert to T*? Give nsCOMPtr move constructors and move assignment operators from that class, that null out this other pointer when called, to transfer ownership at no cost. (At risk of overplaying my hand, I think I've just described what WebBlink calls PassRefPtr, except for that pertaining to concrete classes whereas nsCOMPtr<T> is for abstract T classes.) I recognize this introduces yet another way to do things. But it enables incremental transition to a completely safe system that prohibits assignment of a method call to a raw pointer, and yet never has problems with leaks. If we work hard at enforcing this on the way in, it can quickly become second nature, I think. Jeff _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform