Elusive Bugs: Crash when clicking zoom buttons after a file failed to open

I actually found this by accident the other day. I was toying around with the latest build of Paint.NET, fresh out of the compiler’s oven, and I noticed some weird behavior. I had pre-ordered BioShock on Steam about 10 seconds after I read it was available on there (Tuesday can’t come fast enough!), and was pawing through the files that had been downloaded on my system. There was a bitmap and a PNG, and so of course I had to check them out!

After right clicking the image and choosing Edit, Paint.NET started up and gave an error saying it couldn’t open the image. After a few seconds of wondering why, I realized it was simply because the files were still in encrypted form. Steam is very careful about their release dates! (and rightfully so, of course).

But, what I noticed was that the tool windows and the toolbar were still interactive, even though there were no images open. They’re supposed to be disabled! This is a behavior glitch, of course, but if you can’t crash the app or get it into a bad state then it’s a bug I’m willing to punt until the next release (or just “won’t-fix” forever). So I started clicking on everything in the toolbars and tool windows, half expecting it to crash or worse. Everything was working great though, which I was happily surprised by.

Oops, except that when I clicked on either the Zoom In or Zoom Out buttons, it did crash 😦

Exception details:
System.NullReferenceException: Object reference not set to an instance of an object.
at PaintDotNet.AppWorkspace.ViewConfigStrip_ZoomIn(Object sender, EventArgs e)
at PaintDotNet.ViewConfigStrip.OnZoomIn()
at PaintDotNet.ViewConfigStrip.OnItemClicked(ToolStripItemClickedEventArgs e)

Darn it! Well, the fix was easy enough, all I had to do was check to make sure that ActiveDocumentWorkspace (an internal property of Paint.NET’s AppWorkspace class) property was non-null before doing anything with it.

But wait, there’s more! I’ve actually been receiving e-mails with this specific crash for months! I never knew how to reproduce the crash, and therefore had no way to fix it.

This bug is reproducible in Paint.NET v3.0 through v3.10 Beta 2. It is fixed for the finalized v3.10 release.


One thought on “Elusive Bugs: Crash when clicking zoom buttons after a file failed to open

Comments are closed.