Value in Gtk_Tree_Store modified by GtkAda ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Value in Gtk_Tree_Store modified by GtkAda ?

Rob Groen

Hello,

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

Regards, Rob

Sample program

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;

 

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Value in Gtk_Tree_Store modified by GtkAda ?

Rob Groen

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

Rob

 

 

On 2016-03-11 11:21, Rob Groen wrote:

<deleted>


_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Value in Gtk_Tree_Store modified by GtkAda ?

Emmanuel Briot
In reply to this post by Rob Groen
> 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.

regards
Emmanuel
_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Loading...