lua-users home
lua-l archive

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


2012/1/13 Ezequiel García <elezegarcia@gmail.com>:
> Hi,
>
> 2012/1/13, jonsmirl@gmail.com <jonsmirl@gmail.com>:
>> I'm trying to get luaCairo (http://www.dynaset.org/dogusanh/luacairo)
>> working on a small ARM based embedded system.  When running the small
>> test programs that come with luaCairo several of them segfault in
>> Lua's sweeplist when exiting.
>
> Which examples are causing the segfault? (The smaller one)

These examples all fail...

cairo_test4oo.lua
cairo_test5.lua
cairo_test5oo.lua

---------------

local cairo = require"lcairo"
local CAIRO = cairo

local w = 320
local h = 240
local outfile = "cairo_test2.png"
--local cs = cairo.image_surface_create(CAIRO.FORMAT_RGB24, w, h)
--local cr = cairo.create(cs)

-- option:0
-- local cs = cairo.ImageSurface(CAIRO.FORMAT_RGB24, w, h)
-- local cr = cairo.Context(cs)
-- option:1
-- local crlud = cairo.create(cs)
-- local cr = cairo.ContextFromLUD(crlud, true) -- true:give
ownership, default:false
-- option:2

local cs = cairo.ImageSurface(CAIRO.FORMAT_RGB24, w, h)
local cr = cairo.Context(cs)


cr:set_source_rgb(1, 1, 1)
cr:paint()

cr:set_source_rgb(0, 0, 0)
cr:select_font_face("Sans", CAIRO.FONT_SLANT_NORMAL, CAIRO.FONT_WEIGHT_BOLD)
cr:set_font_size(w/6)
cr:move_to(0, h/4)
cr:show_text("Hello cairo!")

---> comment out the next line and it will work. It seems that
changing the font_face causes the corruption
cr:select_font_face("Sans", CAIRO.FONT_SLANT_NORMAL, CAIRO.FONT_WEIGHT_NORMAL)

cr:set_font_size(w/8)
cr:move_to(0, 3*h/4)
cr:text_path("Lua calling...")
cr:set_source_rgb(0.5, 0.5, 1)
cr:fill_preserve()
cr:set_source_rgb(0, 0, 0)
cr:set_line_width(w/200)
cr:stroke()

--cairo.surface_write_to_png(cs, outfile)
cs:write_to_png(outfile)


>
>> lua seems to work fine on its own. And my standalone programs using
>> Cairo work too. So my suspicions are on the wrappers in luaCairo.
>
> Maybe, the lua binding code (i.e. luacairo code itself) is not
> releasing or destroying some resources. This should be done using
> __gc.
>
> I would compare a minimal faulting luacairo example with its pure C
> cairo counterpart, and then look for non-released resources in
> luacairo code.
>
> Hope I am clear enough.
> Ezequiel.
>



-- 
Jon Smirl
jonsmirl@gmail.com