Part: refactor PropertyPartShape::SaveDocFile and PropertyPartShape::RestoreDocFile

Set exception mask of std::istream::failbit | std::istream::badbit to istream to make sure it raises an exception for corrupted input files.
See: https://forum.freecadweb.org/viewtopic.php?p=536747
This commit is contained in:
wmayer
2022-03-11 22:06:38 +01:00
parent cb5334a98c
commit ec8353ba99
3 changed files with 115 additions and 86 deletions

View File

@@ -637,9 +637,9 @@ void PlyReader::read(const std::string& filename)
if (alpha != max_size)
a = data(i, alpha);
colors.emplace_back(static_cast<float>(r)/255.0f,
static_cast<float>(g)/255.0f,
static_cast<float>(b)/255.0f,
static_cast<float>(a)/255.0f);
static_cast<float>(g)/255.0f,
static_cast<float>(b)/255.0f,
static_cast<float>(a)/255.0f);
}
}
else if (types[red] == "float") {
@@ -1085,9 +1085,9 @@ void PcdReader::read(const std::string& filename)
uint32_t g = (packed >> 8) & 0xff;
uint32_t b = packed & 0xff;
colors.emplace_back(static_cast<float>(r)/255.0f,
static_cast<float>(g)/255.0f,
static_cast<float>(b)/255.0f,
static_cast<float>(a)/255.0f);
static_cast<float>(g)/255.0f,
static_cast<float>(b)/255.0f,
static_cast<float>(a)/255.0f);
}
}
else if (types[rgba] == "F") {
@@ -1105,9 +1105,9 @@ void PcdReader::read(const std::string& filename)
uint32_t g = (packed >> 8) & 0xff;
uint32_t b = packed & 0xff;
colors.emplace_back(static_cast<float>(r)/255.0f,
static_cast<float>(g)/255.0f,
static_cast<float>(b)/255.0f,
static_cast<float>(a)/255.0f);
static_cast<float>(g)/255.0f,
static_cast<float>(b)/255.0f,
static_cast<float>(a)/255.0f);
}
}
}