mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Fixed filedata not being cleaned up when love.image.newImageData(filepath) fails
This commit is contained in:
@@ -53,7 +53,15 @@ ImageData::ImageData(Data *data)
|
|||||||
ImageData::ImageData(filesystem::File *file)
|
ImageData::ImageData(filesystem::File *file)
|
||||||
{
|
{
|
||||||
Data *data = file->read();
|
Data *data = file->read();
|
||||||
load(data);
|
try
|
||||||
|
{
|
||||||
|
load(data);
|
||||||
|
}
|
||||||
|
catch (love::Exception &)
|
||||||
|
{
|
||||||
|
data->release();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
data->release();
|
data->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,10 +132,10 @@ void ImageData::load(Data *data)
|
|||||||
|
|
||||||
create(width, height, ilGetData());
|
create(width, height, ilGetData());
|
||||||
}
|
}
|
||||||
catch(std::exception &)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
ilDeleteImages(1, &image);
|
ilDeleteImages(1, &image);
|
||||||
throw;
|
throw love::Exception("%s", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
ilDeleteImages(1, &image);
|
ilDeleteImages(1, &image);
|
||||||
|
|||||||
@@ -1361,8 +1361,6 @@ void main() {
|
|||||||
end
|
end
|
||||||
|
|
||||||
function love.graphics._shaderCodeToGLSL(vertexcode, pixelcode)
|
function love.graphics._shaderCodeToGLSL(vertexcode, pixelcode)
|
||||||
local vertexarg, pixelarg = vertexcode, pixelcode
|
|
||||||
|
|
||||||
if vertexcode then
|
if vertexcode then
|
||||||
local s = vertexcode:gsub("\r\n\t", " ")
|
local s = vertexcode:gsub("\r\n\t", " ")
|
||||||
s = s:gsub("(%w+)(%s+)%(", "%1(")
|
s = s:gsub("(%w+)(%s+)%(", "%1(")
|
||||||
@@ -1373,7 +1371,6 @@ void main() {
|
|||||||
vertexcode = nil -- first argument doesn't contain vertex shader code
|
vertexcode = nil -- first argument doesn't contain vertex shader code
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if pixelcode then
|
if pixelcode then
|
||||||
local s = pixelcode:gsub("\r\n\t", " ")
|
local s = pixelcode:gsub("\r\n\t", " ")
|
||||||
s = s:gsub("(%w+)(%s+)%(", "%1(")
|
s = s:gsub("(%w+)(%s+)%(", "%1(")
|
||||||
@@ -1388,7 +1385,6 @@ void main() {
|
|||||||
if vertexcode then
|
if vertexcode then
|
||||||
vertexcode = createVertexCode(vertexcode)
|
vertexcode = createVertexCode(vertexcode)
|
||||||
end
|
end
|
||||||
|
|
||||||
if pixelcode then
|
if pixelcode then
|
||||||
pixelcode = createPixelCode(pixelcode)
|
pixelcode = createPixelCode(pixelcode)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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,
|
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,
|
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,
|
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,
|
0x09, 0x09, 0x69, 0x66, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x74, 0x68,
|
||||||
0x65, 0x6e, 0x0a,
|
0x65, 0x6e, 0x0a,
|
||||||
0x09, 0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65,
|
0x09, 0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x72, 0x74, 0x65,
|
||||||
|
|||||||
Reference in New Issue
Block a user