Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Catching a faulty image with Structured Exception Handling

Sign in to follow this  


Work continues on ThumbView2, albeit slowly. Today a bug occurred, and just as it did in ThumbView1 it crashed and brought Windows (explorer.exe) down with it. Since ThumbView is a shell extension, it's a COM object run from a DLL by the OS shell itself. So if the DLL crashes, so does the shell.

As with the first version, the crash wasn't from the ThumbView code I've written but from the 3rd party image loading library failing to load an image. I don't have much power over that, and even if I did it would be too late since it's already crashed a users computer - that's not nice now is it?

Naturally, I have to run the image loading in some safe way. An own thread? An own DLL? Something! The answer came with structured exception handling (SEH). The __try and __except blocks lets me catch and handle both software and hardware exceptions. So dereferenced null-pointers and the like get catched! Right now I just log the error with OutputDebugString and read that with DebugView.

Completely superior! Holy banana! The faulty image is ref.xwd but I just didn't print that, since it would be too useful. ^^

So now I can detect that an image broke the image library. That's hawt if you're the image library writer. To fix that you'll need the actual image. For ThumbView though. What should happen?
* Display a default "broken image" icon?
* Tell the user with a MessageBox that a broken thumbnail was encountered and I'd like him to report the error?
* Just report the error anyway?
* Log the error?
* Allow error report on right-click?
* Erase all .sys files on the hard drive?

Because what I want from the user is: the ThumbView version, OS version, full image file path (to find Unicode problems), and of course the image. I'd like a system that asked the user if I could have the data, collected it, compressed it to a zip, and send it over! But I'll have to log the image so I don't report it more than once; since the user will get annoyed by the system asking to send a report every time he reloads a folder with a broken image...
Sign in to follow this  


Recommended Comments

Man, there's NOTHING more annoying than message boxes popping up all the time! They trigger the same natural response that you have for spam. :P So I wouldn't go with that.

Ok, here's how I would do it:
1) Don't bother sending files over 200kb or so (send the report but not the file). I wouldn't want to upload 5megs just to give the developer debug information!
2) Pop up one of those yellow tip boxes, posing the problem and asking to click. Then a more elaborate textbox shows up - send a report or forget it. Maybe the image is a bit too cheeky to send. +:o)
3) Either choice will throw the file in a list so that the program remembers not to bother the user with it anymore. Better than a list, attach the info to the file (no clue how this would be done though! :P ).
4) If you have a list, clean it up from time to time. Chose a few files at random and check if they're still there.

Huh... I guess that would work ok :)

Share this comment

Link to comment
Guest Anonymous Poster


Firstly ... congratulations on the great work on ThumbView and ThumbView2.

I was facing some issues with your project, was wondering if you could help me out with them.

Here is the scenario:
I am a 3d artist by profession & a coder by hobby. I was making this small app for personal use which would help me keep a repository of all art that i have done in the past.

I also thought about getting a dynamic site of mine uploaded, where I could show off my work. Also, have real-time status of art (image files) for my clients online (since I also do a bit of freelancing).
I was thinking of using your ThumbView control to generate a preview image of my image files, converting these thumbnails to small GIFs or JPEGs & saving them separately in a folder. These GIFs would be supplied via a web service to may web page whenever my client wants to take a look at the progress of his work. Thus giving him realtime status.

The problem is that my art assets dont just include TGA, JPEG or GIfs but they also include Max, Maya & ZBrush files, which, if I understand correctly .. are not supported by ThumView.

However, I came across the ThumbView ActiveX for .NET 2.0. This could have solved my problem, since it generates all thumbnails that have a preview in Windows (my windows shows me previews for max & maya files) . The only problem is that using this control I am not able to get the actual image which has been generated. I would need a handle to this image so that I can save it on disk as a GIF or JPEG, etc.

This was a long comment ... i know ;)
But i just hope I hv communicated my issues completely. Here thay are again in a brief:
1) Some way of showing thumbnails for .max, .ma, .mb, .ztl files (with or without using ThumbView)
2) Or, Getting a handle to the image visible in the ThumbView 2 ActiveX control so that the image can be saved by me on local disk.

Your answer (or no answer ;) ) will not change my views on this great code that U've written. Its very impressive :)
But yes, if you could take out a li'l time to help me out on this, then it'll really mean a lot to me.

Keep up the gud work,

[Please replace 'at' with the @ symbol - i use it for countering SPAM :-)]

Share this comment

Link to comment

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
  • 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!