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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-01-15 18:37:08 +01:00
parent 8b3087dc4e
commit 43896f68ca
1 changed files with 5 additions and 2 deletions

View File

@ -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)
{
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;
}