From: Mikko Rasa Date: Wed, 29 May 2013 20:04:50 +0000 (+0300) Subject: Check the return value of open_from_sources since it no longer throws X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=38cb882b67cf1e31473c9a0c1c9ed12418e059e5;p=libs%2Fgltk.git Check the return value of open_from_sources since it no longer throws --- 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; }