From 43896f68ca3ab82848352f348b060a0539bfe844 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 15 Jan 2016 18:37:08 +0100 Subject: [PATCH] drawable.surface: Return nil if there is a surface Before this commit, it would return a NULL pointer as a lightuserdata. Signed-off-by: Uli Schlachter --- objects/drawable.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/objects/drawable.c b/objects/drawable.c index 5339529c..1d4b3e4d 100644 --- a/objects/drawable.c +++ b/objects/drawable.c @@ -124,8 +124,11 @@ drawable_set_geometry(lua_State *L, int didx, area_t geom) static int luaA_drawable_get_surface(lua_State *L, drawable_t *drawable) { - /* Lua gets its own reference which it will have to destroy */ - lua_pushlightuserdata(L, cairo_surface_reference(drawable->surface)); + if (drawable->surface) + /* Lua gets its own reference which it will have to destroy */ + lua_pushlightuserdata(L, cairo_surface_reference(drawable->surface)); + else + lua_pushnil(L); return 1; }