diff options
author | chai <chaifix@163.com> | 2018-05-18 14:39:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-05-18 14:39:38 +0800 |
commit | 1b773ad2c250e09c09c065eb3eec64bfebde09ca (patch) | |
tree | b3f1f367694d5f86cc0caa7f4eea2e6a1d3424c5 /src/script/graphics/luaopen_Image.cpp | |
parent | 91a592da979827b1735901388dba8712e6e3ecf3 (diff) |
修改userdata创建方式
Diffstat (limited to 'src/script/graphics/luaopen_Image.cpp')
-rw-r--r-- | src/script/graphics/luaopen_Image.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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; } |