mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-11 15:39:12 +08:00
Format error message.
Add regression test of issue-416.
This commit is contained in:
parent
b534b6b0d8
commit
877d856e71
1
tests/issue-416.gltf
Normal file
1
tests/issue-416.gltf
Normal file
@ -0,0 +1 @@
|
||||
{"images":[{"uri":"%!QAAAQAAA5"}],"asset":{"version":""}}
|
@ -738,3 +738,22 @@ TEST_CASE("filesize-check", "[issue-416]") {
|
||||
|
||||
REQUIRE(false == ret);
|
||||
}
|
||||
|
||||
TEST_CASE("load-issue-416-model", "[issue-416]") {
|
||||
|
||||
tinygltf::Model model;
|
||||
tinygltf::TinyGLTF ctx;
|
||||
std::string err;
|
||||
std::string warn;
|
||||
|
||||
bool ret = ctx.LoadASCIIFromFile(&model, &err, &warn, "issue-416.gltf");
|
||||
if (!warn.empty()) {
|
||||
std::cout << "WARN:" << warn << std::endl;
|
||||
}
|
||||
if (!err.empty()) {
|
||||
std::cerr << "ERR:" << err << std::endl;
|
||||
}
|
||||
|
||||
// external file load fails, but reading glTF itself is ok.
|
||||
REQUIRE(true == ret);
|
||||
}
|
||||
|
12
tiny_gltf.h
12
tiny_gltf.h
@ -4177,8 +4177,8 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err,
|
||||
if (!uri_cb->decode(uri, &decoded_uri, uri_cb->user_data)) {
|
||||
if (warn) {
|
||||
(*warn) += "Failed to decode 'uri' for image[" +
|
||||
std::to_string(image_idx) + "] name = [" + image->name +
|
||||
"]\n";
|
||||
std::to_string(image_idx) + "] name = \"" + image->name +
|
||||
"\"\n";
|
||||
}
|
||||
|
||||
// Image loading failure is not critical to overall gltf loading.
|
||||
@ -4190,8 +4190,8 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err,
|
||||
/* checksize */ false, /* max file size */ max_file_size, fs)) {
|
||||
if (warn) {
|
||||
(*warn) += "Failed to load external 'uri' for image[" +
|
||||
std::to_string(image_idx) + "] name = [" + decoded_uri +
|
||||
"]\n";
|
||||
std::to_string(image_idx) + "] name = \"" + decoded_uri +
|
||||
"\"\n";
|
||||
}
|
||||
// If the image cannot be loaded, keep uri as image->uri.
|
||||
return true;
|
||||
@ -4200,8 +4200,8 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err,
|
||||
if (img.empty()) {
|
||||
if (warn) {
|
||||
(*warn) += "Image data is empty for image[" +
|
||||
std::to_string(image_idx) + "] name = [" + image->name +
|
||||
"] \n";
|
||||
std::to_string(image_idx) + "] name = \"" + image->name +
|
||||
"\" \n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user