From 38cb882b67cf1e31473c9a0c1c9ed12418e059e5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 29 May 2013 23:04:50 +0300 Subject: [PATCH] Check the return value of open_from_sources since it no longer throws --- source/resources.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/source/resources.cpp b/source/resources.cpp index 36be79e..8cdd0ad 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -49,17 +49,19 @@ GL::Texture2D *Resources::create_texture(const string &name) { string ext = FS::extpart(name); if(ext==".png" || ext==".jpg") - { - IO::Seekable *io = open_from_sources(name); - Graphics::Image image; - image.load_io(*io); - GL::Texture2D *tex = new GL::Texture2D; - tex->set_min_filter(GL::LINEAR); - tex->image(image); - return tex; - } - else - return 0; + if(IO::Seekable *io = open_from_sources(name)) + { + Graphics::Image image; + image.load_io(*io); + delete io; + + GL::Texture2D *tex = new GL::Texture2D; + tex->set_min_filter(GL::LINEAR); + tex->image(image); + return tex; + } + + return 0; } -- 2.43.0