Sign in to follow this  

GetClipper - annoying exception

Recommended Posts

Replicon    306
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
S1CA    1418
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this