openmedicus / gtk-sharp

DEPRECATED: Use https://github.com/GLibSharp/GtkSharp or https://github.com/GtkSharp/GtkSharp
Other
22 stars 6 forks source link

Fix System.Array usage in {List,Tree}Store #20

Closed grendello closed 7 years ago

grendello commented 7 years ago

{List,Tree}Store.AppendValues overloads which take System.Array as their 'values' parameter incorrectly pass the array down to SetValues. The latter expects a 'params object[]' array of parameters but passing an instance of System.Array to such method will NOT pass the contents of System.Array instance into the 'params' method as separate members of the parms array. It will instead box System.Array and the params method will receive one parameter of type System.Array instead of X parameters of various types. This affects the following example code:

var store = new TreeStore (typeof (string), typeof (int)); store.AppendValues ("One", 1);

If the column configured to retrieve the 'string' value reads data from this store it will instead get an instance of System.Array and the node displayed by the TreeView will have no text, won't be clickable etc.

The fix implemented here is to "explode" the System.Array into a separate array of the 'object[]' type.

The 'TreeStore.AppendValues (params object[] values)' overload no longer calls the 'TreeStore.Appendvalues (Array values)' overload since the indirection only wastes time and memory. It now directly calls SetValues.