[EMAIL PROTECTED] wrote: > This morning while browsing I noticed this message about scope. > > http://groups.google.com/group/mozilla.dev.embedding/browse_thread/thread/4061a9fd077316b8/fc3b43cb2ad20677?lnk=gst&q=nsIPrintSettings#fc3b43cb2ad20677 > > I had thought that all nsCOMPtr references were automatically de- > referenced once they go out of scope. So the following within a > method will orphan settings when said method is exited? Does everyone > trust the GC'ing or are they setting the reference to 0 explicitly?
Are you talking about C++, or about Java? The thread you cite is about Java XPCOM binding, but the code below looks C++ to me. There's no GC in C++. > nsCOMPtr<nsIPrintSettings> settings; > printing->GetGlobalPrintSettings((nsIPrintSettings**)&settings); This should be nsCOMPtr<nsIPrintSettings> settings; printing->GetGlobalPrintSettings(getter_AddRefs(settings)); And yes, nsCOMPtr destructor will call Release() on the interface pointer when 'settings' variable goes out of scope. > PS Those google validation characters are ridiculous!!! I must admit I have no idea what you are talking about. Igor Tandetnik _______________________________________________ dev-embedding mailing list dev-embedding@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-embedding