Work around a bug in LGI
cairo_get_source() is not bound correctly, leading to use-after-free bugs. Cairo catches this and crashes. Work around this by preserving the current source in a different way. Instead of using cairo_get_source() and later cairo_set_source(), this commit wraps everything that changes the current source between cairo_save() and cairo_restore(). Thus, cairo saves the current source for us without us having to grab an explicit reference. Works-around: https://github.com/pavouk/lgi/issues/210 Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
67cf1469f0
commit
ba75da7976
|
@ -30,8 +30,6 @@ end
|
|||
|
||||
-- Prepare drawing the children of this widget
|
||||
function background:before_draw_children(context, cr, width, height)
|
||||
local source = self._private.foreground or cr:get_source()
|
||||
|
||||
-- Redirect drawing to a temporary surface if there is a shape
|
||||
if self._private.shape then
|
||||
cr:push_group_with_content(cairo.Content.COLOR_ALPHA)
|
||||
|
@ -39,11 +37,14 @@ function background:before_draw_children(context, cr, width, height)
|
|||
|
||||
-- Draw the background
|
||||
if self._private.background then
|
||||
cr:save()
|
||||
cr:set_source(self._private.background)
|
||||
cr:rectangle(0, 0, width, height)
|
||||
cr:fill()
|
||||
cr:restore()
|
||||
end
|
||||
if self._private.bgimage then
|
||||
cr:save()
|
||||
if type(self._private.bgimage) == "function" then
|
||||
self._private.bgimage(context, cr, width, height,unpack(self._private.bgimage_args))
|
||||
else
|
||||
|
@ -52,9 +53,8 @@ function background:before_draw_children(context, cr, width, height)
|
|||
cr:rectangle(0, 0, width, height)
|
||||
cr:fill()
|
||||
end
|
||||
cr:restore()
|
||||
end
|
||||
|
||||
cr:set_source(source)
|
||||
end
|
||||
|
||||
-- Draw the border
|
||||
|
|
Loading…
Reference in New Issue