Skip to content

Boxed types and lifetime ... #41

Description

@passenger94

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions