Free resource problem - GetTextExstension



Hi,

 

I’m tiring to use pango with cairo.

 

I need to know the size of a rendered text. For this purpose I’ve used this code

 

Classss::MyFunc()

{

            PangoAttribute *pa;

            PangoAttrList *pal;

 

m_ca_pSurface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);

m_ca_pCairo = cairo_create(m_ca_pSurface);

 

pango_layout_set_font_description(m_pa_pLayout, m_pa_pFontDescr);   // m_pa_pLayout  and m_pa_pFontDescr  are previously set

            pango_cairo_update_layout(m_ca_pCairo, m_pa_pLayout);                    

 

   

            pal = pango_layout_get_attributes(m_pa_pLayout);

pal = pango_attr_list_new();

            pango_layout_set_attributes(m_pa_pLayout, pal);

            pango_attr_list_unref(pal);

           

            pa = pango_attr_size_new(m_sFontSize * PANGO_SCALE);

            pa = pango_attr_weight_new(m_pangoWeight);                           // pangoWeight is previously set

            pango_attr_list_change(pal, pa);

            pango_layout_set_attributes(m_pa_pLayout, pal);

 

            pango_layout_get_pixel_size(m_pa_pLayout, width, height);

 

            If I add this line I get a crash…WHY?

// pango_attribute_destroy(pa);

 

}

 

The problem is that the the allocated memory is not free. A lot of memory remains allocated.

 

Can someone help me?

Which is the right way to get the text extension and free usage memory?

 

Thanks a lot

Andrea Ricchetti

 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]