[gtkada] Add_From_File with null for Error.
Pascal
p.p14 at orange.fr
Wed Mar 5 21:14:13 CET 2014
Hello Emmanuel,
In one hand, if you don't care about null then you can pass directly the parameter Error to GTK+ function, as:
function Add_From_File
(Builder : not null access Gtk_Builder_Record;
Filename : UTF8_String;
Error : access Glib.Error.GError) return Guint
is
function Internal
(Builder : System.Address;
Filename : Interfaces.C.Strings.chars_ptr;
Acc_Error : access Glib.Error.GError) return Guint;
pragma Import (C, Internal, "gtk_builder_add_from_file");
— Acc_Error : aliased Glib.Error.GError;
Tmp_Filename : Interfaces.C.Strings.chars_ptr := New_String (Filename);
Tmp_Return : Guint;
begin
Tmp_Return := Internal (Get_Object (Builder), Tmp_Filename, Error); — Acc_Error
Free (Tmp_Filename);
— Error.all := Acc_Error;
return Tmp_Return;
end Add_From_File;
In other hand, if you care about null you can add "not null" on the GTKAda parameter Error, as:
function Add_From_File
(Builder : not null access Gtk_Builder_Record;
Filename : UTF8_String;
Error : not null access Glib.Error.GError) return Guint
Regards, Pascal.
http://blady.pagesperso-orange.fr
Le 3 mars 2014 à 15:31, Emmanuel Briot <briot at adacore.com> a écrit :
>> As in C GTK programming, I put null for Error parameter thus I got:
>> Exception name: CONSTRAINT_ERROR
>> Message: gtk-builder.adb:149 access check failed
>
> This is an error in gtk+ itself, or rather in the .gir file they export.
> Your patch is incorrect since it manually modified a file that is generated
> automatically.
>
> I have put a workaround in GtkAda, but the recommendation is not to
> pass null for the error, you really should not be ignoring errors in the
> first place.
>
> regards
> Emmanuel
More information about the gtkada
mailing list