From 395bb0bea881a14f90f12849c5a4f182a89303bf Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 28 Feb 2015 16:22:02 -0400 Subject: [PATCH] Fixed a crash when Canvas:newImageData should error. --HG-- branch : minor --- src/modules/graphics/Graphics.h | 5 +---- src/modules/graphics/opengl/wrap_Canvas.cpp | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index e29cf9577..50429f256 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -132,10 +132,7 @@ public: struct ColorMask { - bool r; - bool g; - bool b; - bool a; + bool r, g, b, a; bool operator == (const ColorMask &m) const { diff --git a/src/modules/graphics/opengl/wrap_Canvas.cpp b/src/modules/graphics/opengl/wrap_Canvas.cpp index 3a03cde0c..5f6568e9c 100644 --- a/src/modules/graphics/opengl/wrap_Canvas.cpp +++ b/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 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); img->release(); return 1;