From: Mikko Rasa Date: Mon, 23 Dec 2024 15:33:51 +0000 (+0200) Subject: Check if Collection::open_raw succeeded X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=64e26770b93e782acf930c805c8cfc624636d7e0;p=libs%2Fgl.git Check if Collection::open_raw succeeded --- diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index e9a6f4ed..c46e5232 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -157,6 +157,8 @@ void TextureCube::Loader::external_image(TextureCubeFace face, const string &fn) { Graphics::Image img; unique_ptr io = get_collection().open_raw(fn); + if(!io) + throw IO::file_not_found(fn); img.load_io(*io); obj.image(face, img); diff --git a/source/materials/splatmaterial.cpp b/source/materials/splatmaterial.cpp index 9e5e665c..13e54a9a 100644 --- a/source/materials/splatmaterial.cpp +++ b/source/materials/splatmaterial.cpp @@ -1,4 +1,5 @@ #include +#include #include #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 = 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);