[Mono-dev] Patches for mono-winforms
Steven Boswell II
ulatekh at yahoo.com
Sat Jun 16 00:34:37 UTC 2012
Enclosed is a new patch, mostly for discussion purposes, since there's no unit test & I don't know how I would write one for this.
Today, after using my application in a particular way, I got it to crash, putting up an "Exception caught" window. I can't reproduce the problem outside of running it in the MonoDevelop debugger, and there appears to be no way to copy the contents of the stack-trace tab in the exception-caught window (really? how the heck did THIS get missed?), so I can't post the full details. But it starts at System.ComponentModel.Finalize() with a tool-strip-item (the one I selected seconds before the crash), and ends in System.Drawing.GDIPlus.CheckStatus(Status), where it reports "A null reference or invalid value was found [GDI+ status: InvalidParameter]".
I have no idea why a copy of my menu-item is getting finalized; I certainly didn't make a copy of it. The good news is, this crash is consistently repeatable, if I just use my application in the same certain order.
Digging through the stack trace, I arrived at System.Windows.Forms.ToolStripItem.set_InternalOwner, where the owner was being set to null, and right afterwards, CalculateAutoSize() was being called. Why would anyone need to calculate the size of a menu-item that isn't even connected to a menu any more? So, for me, the bug fix was obvious: check if the owner isn't null before calling CalculateAutoSize(). That's what the enclosed patch does.
With this patch, the bug doesn't reproduce, and the menu-item I selected is still there and doing fine.
Any thoughts on the correctness of this bug fix? Or how one would write a unit test for it? Or how to copy the contents of the stack-trace tab in MonoDevelop's exception-caught window?
Steven Boswell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120615/6a3976ad/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mwf-10-ToolStripItem-InternalOwner-set.patch
Type: application/octet-stream
Size: 608 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120615/6a3976ad/attachment-0001.obj>
More information about the Mono-devel-list
mailing list