-
Notifications
You must be signed in to change notification settings - Fork 4
Boxed types and lifetime ... #41
Description
First, Thank you very much for your awesome work !
Unless i miss something, i believe there is something missing in Boxed type : if you take ownership of the C object, like all D Boxed types do, than as it isn't a Gobject it as no ref so it can disappear at any time (?).
I discovered this in a loop where several Boxed types (graphene Rect and Gdk RGBA) are created, the program randomly crashes but always while trying to "g_boxed_free" one of those objects. If, in the loop,i build the C structures on the stack on the D side, and use them to build the D objects than everything is fine.
The code is on my github : https://github.com/passenger94/ListView_Clocks
the function do_snapshot() is the loop.
forgot to mention !
it's an adaptation of the gtk-demo : https://github.com/GNOME/gtk/blob/main/demos/gtk-demo/listview_clocks.c
it's the working code, if you replace for example
GdkRGBA redc = GdkRGBA(1,0,0,1);
auto red = new RGBA(&redc);
snap.appendColor(red, outline.bounds());
by
snap.appendColor(new RGBA(1,0,0,1), outline.bounds());
it crashes after a while.