From 89265107ea9741acabd39e61d1ff52a7f70b5549 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 20 May 2013 14:47:37 -0300 Subject: [PATCH] Fixed SpriteBatch:addg/setg to error properly instead of crash when attempting to use a Geometry without exactly 4 vertices --- .../graphics/opengl/wrap_SpriteBatch.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index 733c277df..3aa50517f 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -63,7 +63,14 @@ int w_SpriteBatch_addg(lua_State *L) float oy = (float)luaL_optnumber(L, 9, 0); float kx = (float)luaL_optnumber(L, 10, 0); float ky = (float)luaL_optnumber(L, 11, 0); - lua_pushnumber(L, t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky)); + try + { + lua_pushnumber(L, t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky)); + } + catch (love::Exception &e) + { + return luaL_error(L, "%s", e.what()); + } return 1; } @@ -99,7 +106,14 @@ int w_SpriteBatch_setg(lua_State *L) float oy = (float)luaL_optnumber(L, 10, 0); float kx = (float)luaL_optnumber(L, 11, 0); float ky = (float)luaL_optnumber(L, 12, 0); - t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky, index); + try + { + t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky, index); + } + catch (love::Exception &e) + { + return luaL_error(L, "%s", e.what()); + } return 0; }