spk121 / guile-gi

Bindings for GObject Introspection and libgirepository for Guile
GNU General Public License v3.0
58 stars 7 forks source link

<CairoContext> from 'draw' signal should not free the context #100

Closed spk121 closed 3 years ago

spk121 commented 3 years ago

It appears that in a GtkWidget draw signal handler, the cairo_t that is referenced in the <CairoContext> that is generated needs an additional cairo_reference so that it is not freed when <CairoContext> is garbage collected, since that cairo_t is owned by the GtkWidget. If a GC occurs during the draw signal, it will hit the

CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&cr->ref_count)

in cairo_destroy

This script demonstrates the bug cairo-bug.scm.txt

spk121 commented 3 years ago

Could be a result of how in gig_value_to_scm_structured_type, boxed types are always copied as GI_TRANSFER_EVERYTHING unless they are GValue or string

LordYuuma commented 3 years ago

That certainly stands out in this file when everything else is transfered with NOTHING. Is there a reason for this?