]> git.tdb.fi Git - libs/gltk.git/commitdiff
Check the return value of open_from_sources since it no longer throws
authorMikko Rasa <tdb@tdb.fi>
Wed, 29 May 2013 20:04:50 +0000 (23:04 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 29 May 2013 20:04:50 +0000 (23:04 +0300)
source/resources.cpp

index 36be79e7914272d76a30c4c5af904c8fa5dc6cee..8cdd0ad8f0b12066adf3b3dfeed9c2029ec304ee 100644 (file)
@@ -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;
 }