Stephen Kinger wrote:
Hi,
 I am coding XPCOM components with the Gecko-sdk-1.7. I have wrote main
classes for that and i verify that the component is well registered by
parsing the file compreg.dat after i run regxpcom program.
Everything work well if I don't use static functions and attributes. I
haven't find something about it on the net, so i ask the question if i can
declare and use statics functions and variables in my own classes, if
somebody has already meet this problem and if he had found a solution.

The problem is not with static variables in general, but with static objects that have destructors. Static nsCOMPtrs are particularly bad: you aren't allowed to hold XPCOM interface references past the xpcom-shutdown notification, so if you forget to assign null to the static comptr sometime during the shutdown process, you'll end up with an object that is released when the app process is being finished by the OS, which is way too late.

So, the general rule of Mozilla development is not to use static class objects with destructors: this includes nsCOMPtrs and the various nsString objects.

--BDS
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to