Browse Source

Fixed a crash when Canvas:newImageData should error.

--HG--
branch : minor
Alex Szpakowski 10 years ago
parent
commit
395bb0bea8
2 changed files with 4 additions and 5 deletions
  1. 1 4
      src/modules/graphics/Graphics.h
  2. 3 1
      src/modules/graphics/opengl/wrap_Canvas.cpp

+ 1 - 4
src/modules/graphics/Graphics.h

@@ -132,10 +132,7 @@ public:
 
 
 	struct ColorMask
 	struct ColorMask
 	{
 	{
-		bool r;
-		bool g;
-		bool b;
-		bool a;
+		bool r, g, b, a;
 
 
 		bool operator == (const ColorMask &m) const
 		bool operator == (const ColorMask &m) const
 		{
 		{

+ 3 - 1
src/modules/graphics/opengl/wrap_Canvas.cpp

@@ -71,7 +71,9 @@ int w_Canvas_newImageData(lua_State *L)
 	int w = luaL_optint(L, 4, canvas->getWidth());
 	int w = luaL_optint(L, 4, canvas->getWidth());
 	int h = luaL_optint(L, 5, canvas->getHeight());
 	int h = luaL_optint(L, 5, canvas->getHeight());
 
 
-	love::image::ImageData *img = canvas->newImageData(image, x, y, w, h);
+	love::image::ImageData *img = nullptr;
+	luax_catchexcept(L, [&](){ img = canvas->newImageData(image, x, y, w, h); });
+
 	luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
 	luax_pushtype(L, "ImageData", IMAGE_IMAGE_DATA_T, img);
 	img->release();
 	img->release();
 	return 1;
 	return 1;