mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 15:01:28 +12:00
overlay_controls.cpp: Improve image_info ctor withstandability
This commit is contained in:
parent
3a1676e558
commit
73ff506b88
1 changed files with 6 additions and 8 deletions
|
@ -27,15 +27,15 @@ namespace rsx
|
||||||
{
|
{
|
||||||
image_info::image_info(const char* filename)
|
image_info::image_info(const char* filename)
|
||||||
{
|
{
|
||||||
if (!fs::is_file(filename))
|
fs::file f(filename);
|
||||||
|
|
||||||
|
if (!f)
|
||||||
{
|
{
|
||||||
rsx_log.error("Image resource file `%s' not found", filename);
|
rsx_log.error("Image resource file `%s' could not be opened (%s)", filename, fs::g_tls_error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> bytes;
|
auto bytes = f.to_vector<u8>();
|
||||||
fs::file f(filename);
|
|
||||||
f.read(bytes, f.size());
|
|
||||||
data = stbi_load_from_memory(bytes.data(), ::narrow<int>(f.size()), &w, &h, &bpp, STBI_rgb_alpha);
|
data = stbi_load_from_memory(bytes.data(), ::narrow<int>(f.size()), &w, &h, &bpp, STBI_rgb_alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,9 +46,7 @@ namespace rsx
|
||||||
|
|
||||||
image_info::~image_info()
|
image_info::~image_info()
|
||||||
{
|
{
|
||||||
stbi_image_free(data);
|
if (data) stbi_image_free(data);
|
||||||
data = nullptr;
|
|
||||||
w = h = bpp = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource_config::resource_config()
|
resource_config::resource_config()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue