[gtkada] Gtk.Tree_Model_Filter API / usage

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Wed Dec 26 21:22:40 CET 2007


On Mon, 24 Dec 2007 15:24:44 +0100, you wrote:

> I had problems using Gtk.Tree_Model_Filter API.
> The problem is with functions like:
>    function Get_Model
>      (Filter : access Gtk_Tree_Model_Filter_Record)
>       return Gtk.Tree_Model.Gtk_Tree_Model;
>    --  Returns a pointer to the child model of Filter.
> 
> In my application, I create a new filter type (e.g. Foo_Filter_Record) 
> by deriving Gtk.Tree_Model_Filter_Record.
>    type Foo_Filter_record is new Gtk.Tree_Model_Filter_record with ...
>    type Foo_Filter is access all Foo_Filter_Record'Class;
>    ...
> 
> With this context:
>    Foo : Foo_Filter;
>    XXX : Gtk.Tree_Model.Gtk_Tree_Model;
> 
> With Ada05 notation, I can write:
>    XXX := Foo.Get_Model;
> 
> It compiles and runs as expected.
> 
> With Ada95 notation, I can not write:
>    XXX := Get_Model (Foo);
> 
> I have to write:
>    XXX := Get_Model (Gtk_Tree_Model_Filter_Record (Foo.all)'Access);
> Which works, but is quite "heavy" to use.

Hmm,

   Get_Model (Foo)

should work with Ada 95.

> Notice that with GNAT GPL 2007, when I write:
>    XXX := Get_Model (Gtk_Tree_Model_Filter (Foo));
> this compiles (:-(), but raises an exception at runtime, which is really 
> disappointing.
> 
> Is this  problem in my way of writing things (using Ada95 notation) ?

No, I guess it is probably a problem with accessibility checks failing at
run time.

> Is this function really intended to be overridden?
> Shouldn't it be written like this:
>    function Get_Model
>      (Filter : access Gtk_Tree_Model_Filter_Record'Class) -- Added 'Class
>       return Gtk.Tree_Model.Gtk_Tree_Model;
>    --  Returns a pointer to the child model of Filter.
> 
> Is there any way to know, from gtk doc/src, when a function is intended 
> to be overridden or not?

Well, when it is declared abstract. (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list