I try to use cairo to draw_text on screen but mac Os X instrument tells me that I have dangling pointer cause by pango_layout_get_pixel_size or pango_layout_get_baseline .. actuelly the first function which needs to have PangoLines and store them in Layout variable. In every code show on the documentation and example you juste have to g_object_unref(layout) at the end ... but still ... those pointers allocate by itemized_state_init (inside pango_layout_get_pixel_size for ex) are not freed.
Am I doing something wrong ?
double posX = somevalue;
double posY = somevalue;
cairo_save (CurCairoState);
PangoLayout *layout = pango_cairo_create_layout (CurCairoState);
pango_layout_set_text (layout, text, -1);
pango_layout_set_font_description (layout, curCairoContext->font);
int width, height;
pango_layout_get_pixel_size (layout, &width, &height);
int b = (int)(pango_layout_get_baseline (layout) / PANGO_SCALE);
/* applying alignment attribute */
switch (curCairoContext->textAnchor) {
case GMiddle:
posX = posX - (width / 2.0);
break;
case GEnd:
posX = posX - width;
break;
}
cairo_move_to (CurCairoState, posX, posY - b);
pango_cairo_show_layout (CurCairoState, layout);
g_object_unref (layout);
cairo_restore (CurCairoState);
and the result of the allocation in Instrument
thanx to any reply !
EDIT: here is the new screenshot after using G_SLICE=always-malloc G_DEBUG=gc-friendly. Thoses dangling pointers became leaks for "instrument"
EDIT (no solution found) :
I downloaded the sources of pango-1.40.3, compiled it and installed it with markers of my own and I don't understand why I'have got those dangling pointers on MacOS because I'm going through : pango_layout_finalize and pango_layout_clear_lines and layout->ref_count=0 when I call g_obejct_unref (layout)