Discussion:
Errors using gtk.font_button in gtkada (gtk3)
(too old to reply)
Gavin McCord
2019-02-11 23:04:52 UTC
Permalink
Strange one here, at least to me.

I'm running Slackware 14.2, using the XFCE 4.12
desktop environment and GNAT 2018 (though I've
encountered this problem with an older version
of GNAT also).

I created a small program "test" to take input
from a GEntry and insert it into a Text_View. It
doesn't do much else, but works okay.

Since then I've added a Font_Button to allow the
user to change the font within the Text_View.

I get an error though when I click on the font
button for the first time:

"(test:2564): Gtk-CRITICAL **:
gtk_tree_model_filter_real_unref_node: assertion
'elt->ref_count > 0' failed"

But the program, font selection included, still
works as expected.

Now all this is using a custom GTK3 theme, based
on the built-in Raleigh. If I then change the
theme to Adwaita I get subsequent errors and
the program exits, as follows.

I start the program, and click the Font_Button.
The above error occurs, as before. At this point
I can still select a font and it changes the
text in the Text_View accordingly.

But if I then try to change the font a second
time, at the point when I click the Font_Button
the following additional errors appear and the
program exits:

"(test:3481): Gtk-CRITICAL **:
gtk_list_store_get_value: assertion
'iter_is_valid (iter, list_store)' failed

(test:3481): GLib-GObject-WARNING **:
../../src/gobject/gtype.c:4268: type id
'0' is invalid

(test:3481): GLib-GObject-WARNING **:
can't peek value table for type '<invalid>'
which is not currently referenced

raised STORAGE_ERROR : stack overflow or
erroneous memory access

I suspect this is not going to be easy to
diagnose as searches for these errors
previously hasn't brought me anything
particularly similar to my situation.

But any thoughts, pointers would
be gratefully received.

Gavin
Dmitry A. Kazakov
2019-02-11 23:45:02 UTC
Permalink
Post by Gavin McCord
Strange one here, at least to me.
I'm running Slackware 14.2, using the XFCE 4.12
desktop environment and GNAT 2018 (though I've
encountered this problem with an older version
of GNAT also).
I created a small program "test" to take input
from a GEntry and insert it into a Text_View. It
doesn't do much else, but works okay.
Since then I've added a Font_Button to allow the
user to change the font within the Text_View.
I get an error though when I click on the font
gtk_tree_model_filter_real_unref_node: assertion
'elt->ref_count > 0' failed"
GTK deploys reference counting. It is a very tricky and difficult to
understand. GTK widgets have so-called "floating" reference when
created. A floating reference is converted into a normal reference when
the widget is put into a container. It is done to spare one line of code
needed to decrement the reference in the sequences like:

Gtk_New (Child);
Box.Pack_Start (Child);
[ Unref (Child) ]

But all other objects are created with normal reference count 1 and need
to be released using Unref when put somewhere.

You seem mess up with references.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Gavin McCord
2019-02-13 21:26:03 UTC
Permalink
No, that makes sense, but I must be missing something
really obvious. I've simplified the code so there's
only a button, a label and the font_button, with one
main program file and a callback package (see below),
though the font_button isn't even connected to a
handler at this point, the error still occurs when
it's clicked on.



test2.adb
---------
with Gtk.Main;
with Gtk.Window; use Gtk.Window;
with Gtk.Box; use Gtk.Box;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Button; use Gtk.Button;
with Gtk.Font_Button; use Gtk.Font_Button;
with Gtk.Label; use Gtk.Label;
with Gtkada.Handlers; use Gtkada.Handlers;
with Test2_Cb; use Test2_Cb;


procedure Test2 is

Win : Gtk_Window;
Vert_Box : Gtk_VBox;
Button : Gtk_Button;
FontButton : Gtk_Font_Button;
Label : Gtk_Label;

begin

Gtk.Main.Init;
Gtk_New (Win);
Win.Set_Default_Size (480, 160);
Win.Set_Title ("FontButton test");
Win.On_Destroy (Main_Quit'Access);
Gtk_New_VBox (Vert_Box, False, 0);
Win.Add (Vert_Box);
Gtk_New (Label, "A label.");
Pack_Start (Vert_Box, Label, True, False, 0);
Gtk_New (FontButton);
Pack_Start (Vert_Box, FontButton, True, False, 0);
Gtk_New (Button, "Quit");
Widget_Callback.Object_Connect
(Button, "clicked",
Widget_Callback.To_Marshaller (Button_Quit'Access),
Win);
Pack_Start (Vert_Box, Button, True, False, 0);
Win.Show_All;
Gtk.Main.Main;

end Test2;
----------


test2_cb.adb
------------
package body Test2_Cb is

procedure Main_Quit (Self : access Gtk_Widget_Record'Class) is
begin
Gtk.Main.Main_Quit;
end Main_Quit;

procedure Button_Quit (Self : access Gtk_Widget_Record'Class) is
begin
Destroy (Self);
end Button_Quit;

end Test2_Cb;
-------------


test2_cb.ads
------------
with Gtk.Main;
with Gtk.Widget; use Gtk.Widget;

package Test2_Cb is

procedure Main_Quit (Self : access Gtk_Widget_Record'Class);
procedure Button_Quit (Self : access Gtk_Widget_Record'Class);

end Test2_Cb;
-------------
Dmitry A. Kazakov
2019-02-13 22:02:04 UTC
Permalink
Post by Gavin McCord
No, that makes sense, but I must be missing something
really obvious. I've simplified the code so there's
only a button, a label and the font_button, with one
main program file and a callback package (see below),
though the font_button isn't even connected to a
handler at this point, the error still occurs when
it's clicked on.
Works OK with GtkAda 3.14.15. What version do you have?
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Gavin McCord
2019-02-13 23:22:15 UTC
Permalink
Post by Dmitry A. Kazakov
Works OK with GtkAda 3.14.15. What version do you have?
3.18.9. Too new?
Gavin McCord
2019-02-13 23:42:08 UTC
Permalink
Post by Gavin McCord
Post by Dmitry A. Kazakov
Works OK with GtkAda 3.14.15. What version do you have?
3.18.9. Too new?
Correction, that's the version distributed with Slackware 14.2,
the version included with GNAT *is* 3.14.15.
Dmitry A. Kazakov
2019-02-14 08:26:01 UTC
Permalink
Post by Gavin McCord
Post by Gavin McCord
Post by Dmitry A. Kazakov
Works OK with GtkAda 3.14.15. What version do you have?
3.18.9. Too new?
Correction, that's the version distributed with Slackware 14.2,
the version included with GNAT *is* 3.14.15.
Does Slackware distribute GtkAda, or 3.18.9 is the version of GTK
itself? GtkAda 3.14.15 is what AdaCore published with the GNAT GPL (or
community edition they call it now). They also have a repository where
one can get the latest changes.

Also, GTK is full of bugs that come and go. Recently I had a massive
memory leak in one version fixed in another. Memory leakage has a direct
connection to reference counting, so I would think it might be a GTK
problem, first.

You could try to upgrade or downgrade and see if the bug persists.
GtkAda usually stays compatible with a number of GTK version.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Gavin McCord
2019-02-14 23:31:11 UTC
Permalink
Slackware only comes with basic Ada support
for GCC. I'm presuming it's an old version of
the FSF GNAT. I don't install that.

I downloaded and installed myself, GNAT and Gtkada
from AdaCore.

I'd love if it were part of the distribution but I
think that pretty unlikely.

I might see if I can downgrade.

Loading...