When I create a Gtk_Tree_Model_Filter without a child model, i.e. using Null_Gtk_Tree_Model as child, then I get a non-null object (and also a textual message in a terminal window).
Now when I store that non-null object in a Gtk_Tree_Store and then retrieve it I get a null value. Is that OK? I can't find something about this behaviour in the documentation. Below is a small sample program to repeat this behaviour.
I am using GPL 2014 and GtkAda 2015 on Windows 7
with Ada.Text_Io; use Ada.Text_Io; with Glib.Object; use Glib.Object; with Gtk.Main; with Gtk.Tree_Model; use Gtk.Tree_Model; with Gtk.Tree_Store; use Gtk.Tree_Store; with Gtk.Tree_Model_Filter; use Gtk.Tree_Model_Filter; procedure Test_Model_Filter_Main is Mf : Gtk_Tree_Model_Filter; Obj : Gobject; Store : Gtk_Tree_Store; Iter : Gtk_Tree_Iter; begin Gtk.Main.Init; Gtk_New (Mf, Null_Gtk_Tree_Model); Obj := Gobject (Mf); if Obj = null then Put_Line ("null object returned"); return; end if; Gtk_New (Store, (1 => Glib.Gtype_Object)); Store.Append (Iter, Null_Iter); Store.Set (Iter, 0, Obj); Obj := Store.Get_Object (Iter, 0); if Obj = null then Put_Line ("object is now null"); end if; end Test_Model_Filter_Main;
Note that in order to observe the noted behaviour gktada\bin must come before GNAT\bin in the PATH environment variable. If the order is reversed no message is given and the value in the store is not set to null
> When I create a Gtk_Tree_Model_Filter without a child model, i.e. using Null_Gtk_Tree_Model as child, then
> I get a non-null object (and also a textual message in a terminal window).
I don't think this is intended use of the API.
A filter must have a child model, and this must be set at creation time since there is no way
to set it later.
The API should force this of course, but since a Gtk_Tree_Model is not an access type, we cannot
explicit set a "not null" constraint. We could add a precondition, but GtkAda is currently in Ada2005
mode, not Ada2012, for backward compatibility.
So for now we cannot really change the API.