From 1b773ad2c250e09c09c065eb3eec64bfebde09ca Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 18 May 2018 14:39:38 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9userdata=E5=88=9B=E5=BB=BA=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script/graphics/luaopen_Image.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/script/graphics/luaopen_Image.cpp') diff --git a/src/script/graphics/luaopen_Image.cpp b/src/script/graphics/luaopen_Image.cpp index 7b9b96a..9506ce4 100644 --- a/src/script/graphics/luaopen_Image.cpp +++ b/src/script/graphics/luaopen_Image.cpp @@ -11,7 +11,10 @@ namespace lua static inline Image* checkImage(lua_State* L) { - return (Image*)luax_checktype(L, 1, TYPE_IMAGE); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_IMAGE); + if (proxy != 0 && proxy != nullptr) + return (Image*)proxy->object; + return nullptr; } static int l_getWidth(lua_State* L) @@ -60,7 +63,9 @@ namespace lua static int l_gc(lua_State* L) { - + Image* i = checkImage(L); + if (i != nullptr) + delete i; return 0; } -- cgit v1.1-26-g67d0