Improved the error message when nil is passed as the first argument to love.image.newImageData (resolves issue #1205).

This commit is contained in:
Alex Szpakowski
2016-08-21 11:22:21 -03:00
parent 154f7cbc7e
commit acde58d311
3 changed files with 22 additions and 11 deletions
+16 -11
View File
@@ -68,19 +68,24 @@ int w_newImageData(lua_State *L)
t->release();
return 1;
}
else if (filesystem::luax_cangetfiledata(L, 1)) // Case 2: File(Data).
{
filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
// Case 2: File(Data).
love::filesystem::FileData *data = love::filesystem::luax_getfiledata(L, 1);
ImageData *t = nullptr;
luax_catchexcept(L,
[&]() { t = instance()->newImageData(data); },
[&](bool) { data->release(); }
);
ImageData *t = nullptr;
luax_catchexcept(L,
[&]() { t = instance()->newImageData(data); },
[&](bool) { data->release(); }
);
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
t->release();
return 1;
luax_pushtype(L, IMAGE_IMAGE_DATA_ID, t);
t->release();
return 1;
}
else
{
return luax_typerror(L, 1, "value");
}
}
int w_newCompressedData(lua_State *L)