Jump to content
  • Advertisement
Sign in to follow this  
Replicon

GetClipper - annoying exception

This topic is 4821 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

I've got a releaseSurface method that should work in the following way: - check if the surface has a clipper attached - if so, then release it - release the surface itself I do the first part like this: if(SUCCEEDED(surface->GetClipper(&clipper))) { // ... release it, etc. } ... The problem is that when there isn't a clipper attached to the surface, instead of failing out in the SUCCEEDED macro (which checks the hresult), it throws an exception! Is there a way to check if a surface has a clipper attached without having to do a stupid mini-try/catch loop to watch for that one exception and ignore it? I assume if you just Release() a surface, it won't release its clipper, but correct me if I'm wrong, in which case there's just plain no point in worrying about a memory leak...

Share this post


Link to post
Share on other sites
Advertisement
DirectDraw functions shouldn't throw C++ exceptions.

Are you certain it's a thrown C++ exception?, could it perhaps be a system exception such as an "Access Violation" ?

You'd get an access violation if "surface" was NULL or some non-pointer value (such as 0xCDCDCDCD or 0xDDDDDDDD for example which are indications of allocated memory which hasn't been used or allocated memory that's recently been free'd). It's worth checking the value of "surface" when the exception occurs.

Calling GetClipper() on a surface which had already been released might cause an access violation (or similar) too.

AFAIK doing a SetClipper(NULL) should be ok without testing whether a clipper is currently set on the surface.

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!