[Gtk-sharp-list] Bugs in TreeModelFilter.custom and TreeModelAdapter.custom
Christian Hoff
christian_hoff at gmx.net
Thu Mar 27 09:29:27 EDT 2008
Hi,
I have figured out two related bugs in the TreeModelFilter and
TreeModelAdapter classes of Gtk#.
Since the SetValue(iter, column, value) methods are not members of the
underlying Gtk+ TreeModel class, they have been added in the Gtk#
implementation(in TreeModel.custom). This makes sense because the two
main implementors of this interface - TreeStore and ListStore - both
provide these methods.
But the TreeModelFilter(which also extends these interfaces) does NOT
implement these SetValue methods. That's why Gtk# has to call the
SetValue method of the child model whenever this method is called in the
TreeModelFilter.
Currently Gtk# assumes that there is a SetValue method for the
TreeModelFilter(something like tree_model_filter_set_value) and calls it
everytime:
public void SetValue (Gtk.TreeIter iter, int column, object value) {
SetValue (iter, column, new GLib.Value (value));
}
But this function is calling itself since a GLib.Value is also an
object. This finally leads to a stack overflow when calling this method
from a Gtk.TreeModelFilter.
I have fixed this error via calling the SetValue method of the child model:
this.Model.SetValue(this.ConvertIterToChildIter(iter), column, value);
There is just one case when this solution won't work: When using a
ModifyFunc that replaces the original columns in the child model(then
the column number in the filter cannot be converted into an "original"
column number in the child model). But as I already reported(maybe a bit
angrily) the ModifyFunc won't work anyway with Gtk#(or at least it has
not worked half a year ago). Maybe a check should be implemented whether
the user has set up a ModifyFunc on the filter and then, if so, throw an
exception.
The second similar bug affects the TreeModelAdapter. Calling the
SetValue methods will also result in a stack overflow due to the same
reason. But this time the adapter has to pass the call to SetValue
method of the implementor class. I implemented this functionality using
reflection and the Invoke() method of the MethodInfo class. A better or
more faster solution is in my opinion not possible.
I have attached two patches for the mentioned problems, both are tested
and work for me; I would be great if you commit them or post me a little
feedback.
Christian Hoff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TreeModelAdapter.custom.patch
Type: text/x-diff
Size: 3602 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20080327/5dbc5274/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TreeModelFilter.custom.patch
Type: text/x-diff
Size: 998 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20080327/5dbc5274/attachment-0001.bin
More information about the Gtk-sharp-list
mailing list