From 9e9eb42f1df6bb786e919eb8b84e794eb257e838 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 19 Mar 2013 09:01:15 -0300 Subject: [PATCH] Fixed filedata not being cleaned up when love.image.newImageData(filepath) fails --- src/modules/image/devil/ImageData.cpp | 14 +++++++++++--- src/scripts/graphics.lua | 4 ---- src/scripts/graphics.lua.h | 3 --- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/modules/image/devil/ImageData.cpp b/src/modules/image/devil/ImageData.cpp index fbe76dc6d..4991d6318 100644 --- a/src/modules/image/devil/ImageData.cpp +++ b/src/modules/image/devil/ImageData.cpp @@ -53,7 +53,15 @@ ImageData::ImageData(Data *data) ImageData::ImageData(filesystem::File *file) { Data *data = file->read(); - load(data); + try + { + load(data); + } + catch (love::Exception &) + { + data->release(); + throw; + } data->release(); } @@ -124,10 +132,10 @@ void ImageData::load(Data *data) create(width, height, ilGetData()); } - catch(std::exception &) + catch(std::exception &e) { ilDeleteImages(1, &image); - throw; + throw love::Exception("%s", e.what()); } ilDeleteImages(1, &image); diff --git a/src/scripts/graphics.lua b/src/scripts/graphics.lua index 4ca933062..e4755cbea 100644 --- a/src/scripts/graphics.lua +++ b/src/scripts/graphics.lua @@ -1361,8 +1361,6 @@ void main() { end function love.graphics._shaderCodeToGLSL(vertexcode, pixelcode) - local vertexarg, pixelarg = vertexcode, pixelcode - if vertexcode then local s = vertexcode:gsub("\r\n\t", " ") s = s:gsub("(%w+)(%s+)%(", "%1(") @@ -1373,7 +1371,6 @@ void main() { vertexcode = nil -- first argument doesn't contain vertex shader code end end - if pixelcode then local s = pixelcode:gsub("\r\n\t", " ") s = s:gsub("(%w+)(%s+)%(", "%1(") @@ -1388,7 +1385,6 @@ void main() { if vertexcode then vertexcode = createVertexCode(vertexcode) end - if pixelcode then pixelcode = createPixelCode(pixelcode) end diff --git a/src/scripts/graphics.lua.h b/src/scripts/graphics.lua.h index 189d3f71b..5b41b2c7b 100644 --- a/src/scripts/graphics.lua.h +++ b/src/scripts/graphics.lua.h @@ -6388,9 +6388,6 @@ const unsigned char graphics_lua[] = 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x54, 0x6f, 0x47, 0x4c, 0x53, 0x4c, 0x28, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x64, 0x65, 0x2c, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6c, 0x63, 0x6f, 0x64, 0x65, 0x29, 0x0a, - 0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x61, 0x72, 0x67, 0x2c, - 0x20, 0x70, 0x69, 0x78, 0x65, 0x6c, 0x61, 0x72, 0x67, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, - 0x63, 0x6f, 0x64, 0x65, 0x2c, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6c, 0x63, 0x6f, 0x64, 0x65, 0x0a, 0x09, 0x09, 0x69, 0x66, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65,