aboutsummaryrefslogtreecommitdiff
path: root/src/script/graphics/luaopen_Canvas.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-05-18 14:39:38 +0800
committerchai <chaifix@163.com>2018-05-18 14:39:38 +0800
commit1b773ad2c250e09c09c065eb3eec64bfebde09ca (patch)
treeb3f1f367694d5f86cc0caa7f4eea2e6a1d3424c5 /src/script/graphics/luaopen_Canvas.cpp
parent91a592da979827b1735901388dba8712e6e3ecf3 (diff)
修改userdata创建方式
Diffstat (limited to 'src/script/graphics/luaopen_Canvas.cpp')
-rw-r--r--src/script/graphics/luaopen_Canvas.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/graphics/luaopen_Canvas.cpp b/src/script/graphics/luaopen_Canvas.cpp
index f869882..a34e3b3 100644
--- a/src/script/graphics/luaopen_Canvas.cpp
+++ b/src/script/graphics/luaopen_Canvas.cpp
@@ -11,7 +11,10 @@ namespace lua
static inline Canvas* checkCanvas(lua_State* L)
{
- return (Canvas*)luax_checktype(L, 1, TYPE_CANVAS);
+ Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_CANVAS);
+ if (proxy != nullptr)
+ return (Canvas*)proxy->object;
+ return nullptr;
}
static int l_getWidth(lua_State* L)
@@ -47,7 +50,9 @@ namespace lua
static int l_gc(lua_State* L)
{
-
+ Canvas* canvas = checkCanvas(L);
+ if (canvas != nullptr)
+ delete canvas;
return 0;
}