changeset 1391:a742f6edaf92

Fixed filedata not being cleaned up when love.image.newImageData(filepath) fails
author Alex Szpakowski <slime73@gmail.com>
date Tue, 19 Mar 2013 09:01:15 -0300
parents 6f1ac9fc80da
children c0cf8bb6ddb6
files src/modules/image/devil/ImageData.cpp src/scripts/graphics.lua src/scripts/graphics.lua.h
diffstat 3 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/modules/image/devil/ImageData.cpp	Mon Mar 18 22:55:41 2013 -0300
+++ b/src/modules/image/devil/ImageData.cpp	Tue Mar 19 09:01:15 2013 -0300
@@ -53,7 +53,15 @@
 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 @@
 
 		create(width, height, ilGetData());
 	}
-	catch(std::exception &)
+	catch(std::exception &e)
 	{
 		ilDeleteImages(1, &image);
-		throw;
+		throw love::Exception("%s", e.what());
 	}
 
 	ilDeleteImages(1, &image);
--- a/src/scripts/graphics.lua	Mon Mar 18 22:55:41 2013 -0300
+++ b/src/scripts/graphics.lua	Tue Mar 19 09:01:15 2013 -0300
@@ -1361,8 +1361,6 @@
 	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 @@
 				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 @@
 		if vertexcode then
 			vertexcode = createVertexCode(vertexcode)
 		end
-
 		if pixelcode then
 			pixelcode = createPixelCode(pixelcode)
 		end
--- a/src/scripts/graphics.lua.h	Mon Mar 18 22:55:41 2013 -0300
+++ b/src/scripts/graphics.lua.h	Tue Mar 19 09:01:15 2013 -0300
@@ -6388,9 +6388,6 @@
 	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,