wibox.drawable: Don't redraw drawables without surfaces (FS#1079)

Thanks to the previous commit, a drawable can no longer have a finished cairo
surface. Instead, it will now have a nil surface. This commit handles this new
possibility.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2013-02-20 14:19:31 +01:00
parent 983001613a
commit 2de450dff9
1 changed files with 4 additions and 1 deletions

View File

@ -19,7 +19,10 @@ local surface = require("gears.surface")
local drawables = setmetatable({}, { __mode = 'k' })
local function do_redraw(self)
local cr = cairo.Context(surface(self.drawable.surface))
local surf = surface(self.drawable.surface)
-- The surface can be nil if the drawable's parent was already finalized
if not surf then return end
local cr = cairo.Context(surf)
local geom = self.drawable:geometry();
local x, y, width, height = geom.x, geom.y, geom.width, geom.height