[Mono-dev] Fix for a 5 year old bug - not yet submitted - opinions welcome

Rob Wilkens robwilkens at gmail.com
Wed Jun 6 02:01:35 UTC 2012


I still have to clean up the code, and create a branch, and submit it, 
but i just fixed a 5 year old bug and if anyone has issues with how i 
did it here is a summary....

the problem report is here:
https://bugzilla.novell.com/show_bug.cgi?id=323154

I found by deduction that the repaint wasn't cancelling the active edit 
box after the row was deleted ..  So while the table updated, the edit 
box with the old value didn't go away...  The repaint was from an 
Invalidate call which stack trace looked something like this:

System.Windows.Forms.DataGrid.CalcAreasAndInvalidate()
    at System.Windows.Forms.DataGrid.RecreateDataGridRows(Boolean recalc)
    at 
System.Windows.Forms.DataGrid.OnListManagerItemChanged(System.Object 
sender, System.Windows.Forms.ItemChangedEventArgs e)
    at 
System.Windows.Forms.CurrencyManager.OnItemChanged(System.Windows.Forms.ItemChangedEventArgs 
e)
    at System.Windows.Forms.CurrencyManager.UpdateIsBinding()
    at 
System.Windows.Forms.CurrencyManager.ListChangedHandler(System.Object 
sender, System.ComponentModel.ListChangedEventArgs e)
    at 
System.Data.DataView.OnListChanged(System.ComponentModel.ListChangedEventArgs 
e)
    at System.Data.DataView.OnRowDeleted(System.Object sender, 
System.Data.DataRowChangeEventArgs args)
    at 
System.Data.DataTable.OnRowDeleted(System.Data.DataRowChangeEventArgs e)
    at System.Data.DataTable.DeletedDataRow(System.Data.DataRow dr, 
DataRowAction action)
    at System.Data.DataRow.Delete()
    at System.Data.DataView.Delete(Int32 index)
    at System.Data.DataRowView.Delete()
    at grid.ProcessCmdKey(Message ByRef msg, Keys keyData)
(etc)

ProcessCmdKey is from user code in sample in bug report...

After the delete, the first thing the DataGrid gets back is an 
OnListManagerItemChanged (as can be seen in stack above)...

Before that would call RecreateDataGridRows(), if it was going to do 
that, i inserted a check to see if we're editing, and if so, i cancel 
the edit, here is a summary of what my patch will look like in 
ONListManagerItemChanged in DataGrid.cs in System.Windows.Forms directory:

                                 if (rows == null || RowsCount != 
rows.Length - (ShowEditRow ? 1 : 0))
+                             {
+                                        if (is_editing)
+                                                CancelEditing ();
                                          RecreateDataGridRows (true);
+                             }

This solved the problem reported.  It is now identical to windows .net 
behavior from what i can see.

I've got to clean up my debug code, and again create a github branch and 
put this change in it, unit tests ran and seem unchanged by this..I 
can't imagine a unit test for this necessarily because it's a 
visual/click-required kind of thing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120605/1bd47cce/attachment-0001.html>


More information about the Mono-devel-list mailing list