]> git.tdb.fi Git - libs/gl.git/commitdiff
Check if Collection::open_raw succeeded
authorMikko Rasa <tdb@tdb.fi>
Mon, 23 Dec 2024 15:33:51 +0000 (17:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 23 Dec 2024 15:44:52 +0000 (17:44 +0200)
source/core/texturecube.cpp
source/materials/splatmaterial.cpp

index e9a6f4ed855cd3de0f0e41994e45929cd4bb05c8..c46e52329177f80d918bcd5ad870ed63225c83dc 100644 (file)
@@ -157,6 +157,8 @@ void TextureCube::Loader::external_image(TextureCubeFace face, const string &fn)
 {
        Graphics::Image img;
        unique_ptr<IO::Seekable> io = get_collection().open_raw(fn);
+       if(!io)
+               throw IO::file_not_found(fn);
        img.load_io(*io);
 
        obj.image(face, img);
index 9e5e665ce62fb20ba8736e0155b922aa6836b0e6..13e54a9ab3f1bf7e6a82d6dc8ae1d7f3ce43922e 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/datafile/rawdata.h>
+#include <msp/io/file.h>
 #include <msp/strings/format.h>
 #include "pbrmaterial.h"
 #include "resources.h"
@@ -116,6 +117,9 @@ void SplatMaterial::upload_sub_map(DataFile::Collection &coll, unsigned index, S
                ++sub.layer;
 
        unique_ptr<IO::Seekable> io = coll.open_raw(sub.source_fn);
+       if(!io)
+               throw IO::file_not_found(sub.source_fn);
+
        char magic[4] = { };
        io->read(magic, 4);
        io->seek(0, IO::S_BEG);