From 989f7143fa40b66fc9e6918423b8ae32bc1327e8 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 17 Apr 2022 16:57:48 +0200 Subject: [PATCH] Prevent a crash when running in Debug mode, Make the RenderableFluxNodes check all files first before failing --- .../renderableplanetimevaryingimage.cpp | 2 ++ .../space/rendering/renderablefluxnodes.cpp | 19 ++++++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/base/rendering/renderableplanetimevaryingimage.cpp b/modules/base/rendering/renderableplanetimevaryingimage.cpp index 76d8e3982d..cc9a258246 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.cpp +++ b/modules/base/rendering/renderableplanetimevaryingimage.cpp @@ -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 diff --git a/modules/space/rendering/renderablefluxnodes.cpp b/modules/space/rendering/renderablefluxnodes.cpp index 05b904465e..4413b6c84c 100644 --- a/modules/space/rendering/renderablefluxnodes.cpp +++ b/modules/space/rendering/renderablefluxnodes.cpp @@ -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