Jump to content
  • Advertisement
Sign in to follow this  
lack o comments

Basic question about releasing interfaces

This topic is 5098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This question has been on my mind a long time, and I don't really know enough about COM or Windows to figure it out myself. Is it safe to release an interface (particularly, one that uses the instance of the app) after WinMain has been exited. For instance, if I wrapped IDirectDraw in a class and its release method was called in a global destructor. My guess has always been, no. But I'm really not sure and just a little curious. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

Personally I'd advise always making sure final releases are done before the end of WinMain.

If the interface has been passed a window handle (such as the focus window used for creating D3D devices or the one used for SetCooperativeLevel() calls), then the final release should happen before the window is destroyed - which usually implies it should happen before the end of WinMain


Having said that, global destructors are handled very soon after the end of WinMain anyway under MSVC - but it's considered messy/bad practice because exactly where they get called and the state of things like the C runtime library isn't guaranteed across different compilers and even different revisions of the same compiler.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!