adding check to texture pointers

This commit is contained in:
Kbz-8
2024-01-26 11:59:57 +01:00
parent 77563b8449
commit e018cad851
4 changed files with 32 additions and 23 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2024/01/20 08:21:37 by maldavid ### ########.fr */
/* Updated: 2024/01/26 11:56:34 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -86,12 +86,20 @@ namespace mlx::core
vkDeviceWaitIdle(Render_Core::get().getDevice().get()); // TODO : synchronize with another method than waiting for GPU to be idle
if(ptr == nullptr)
{
core::error::report(e_kind::error, "wrong texture (NULL)");
core::error::report(e_kind::error, "invalid image ptr (NULL)");
return;
}
else if(std::find_if(_textures.begin(), _textures.end(), [=](const Texture& texture)
{
return &texture == ptr;
}) == _textures.end())
{
core::error::report(e_kind::error, "invalid image ptr");
return;
}
Texture* texture = static_cast<Texture*>(ptr);
if(!texture->isInit())
core::error::report(e_kind::error, "trying to destroy a texture");
core::error::report(e_kind::error, "trying to destroy a texture that has already been destroyed");
else
texture->destroy();
}