Prevent a crash when running in Debug mode, Make the RenderableFluxNodes check all files first before failing

This commit is contained in:
Alexander Bock
2022-04-17 16:57:48 +02:00
parent 5751fe26d3
commit 989f7143fa
2 changed files with 8 additions and 13 deletions
@@ -208,6 +208,8 @@ void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) {
if (isInInterval) {
const size_t nextIdx = _activeTriggerTimeIndex + 1;
if (
// true => we were not in an interval the previous frame but now we are
_activeTriggerTimeIndex == -1 ||
// true => We stepped back to a time represented by another state
currentTime < _startTimes[_activeTriggerTimeIndex] ||
// true => We stepped forward to a time represented by another state
@@ -520,35 +520,26 @@ bool RenderableFluxNodes::isReady() const {
void RenderableFluxNodes::populateStartTimes() {
std::string timeFile;
std::string fileType;
for (const std::string& filePath : _binarySourceFiles) {
timeFile = filePath;
if (filePath.substr(filePath.find_last_of(".") + 1) == "csv") {
fileType = "csv";
timeFile = filePath;
break;
}
else if (filePath.substr(filePath.find_last_of(".") + 1) == "dat") {
fileType = "dat";
timeFile = filePath;
break;
}
else if (filePath.substr(filePath.find_last_of(".") + 1) == "txt") {
fileType = "txt";
timeFile = filePath;
break;
}
//if no file extention but word "time" in file name
else if (filePath.find("time") != std::string::npos &&
filePath.find(".") == std::string::npos)
{
timeFile = filePath;
break;
}
else {
LERROR(fmt::format("Error in file type or naming of file '{}'. ",
"Time meta file supports csv, dat, txt or without file extention ",
"(but then have to include 'time' in filename)", filePath
));
timeFile.clear();
}
}
if (timeFile.empty()) {
@@ -750,6 +741,8 @@ void RenderableFluxNodes::update(const UpdateData& data) {
if (isInInterval) {
const size_t nextIdx = _activeTriggerTimeIndex + 1;
if (
// true => we were not in an interval the previous frame but now we are
_activeTriggerTimeIndex == -1 ||
// true => We stepped back to a time represented by another state
currentTime < _startTimes[_activeTriggerTimeIndex] ||
// true => We stepped forward to a time represented by another state