Open vrotaru opened 4 years ago
Now if I compile the same program with lablgtk2
everything works.
It also works if I move the line
let _locale = GMain.init ()
to the start of the program. Hope this helps.
I guess I've seen the wrongness of my ways. The window is created at class definition time, not at object instantiation time. This changes are enough to fix the problem
- class wrapper =
+ class wrapper () =
- let wrapper = new wrapper
+ let wrapper = new wrapper ()
to fix the problem. Still it will be nice to have a check is_gtk_main_initialized
before the ml_g_object_new
is called.
Not sure how hard is this to add.
The semantics of let
in parameterless classes is very confusing.
Basically the let
is executed at class initialization time, but a new object will be created each time you call new
.
I was not aware of the change of behavior between Gtk2 and Gtk3, since the change is not on the lablgtk side. Of course, the code is incorrect under Gtk2 too, as the critical warning shows.
As for checking for initialization, we could do it before creating widgets. It is very simple to add for wrappers generated by propcc
, but there may be a few raw *_new
functions around, which would require adding the check by hand.
I have a simple program which works with
lablgtk2
but segfaults withlablgtk3
. The programAnd I compile it using
And when I run it segfaults wtih the following stack trace