Fix of #321 and #284 Crash when setting data from octave into an input case

This commit is contained in:
Jacob Støren 2015-06-29 17:03:22 +02:00
parent 08741150c7
commit 2b1e2bb157

View File

@ -547,6 +547,23 @@ public:
// Make sure the size of the retreiving container is correct. // Make sure the size of the retreiving container is correct.
// If it is, this is noops // If it is, this is noops
{
size_t maxRequestedTimeStepIdx = cvf::UNDEFINED_SIZE_T;
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
{
size_t tsId = m_requestedTimesteps[tIdx];
if (maxRequestedTimeStepIdx == cvf::UNDEFINED_SIZE_T || tsId > maxRequestedTimeStepIdx)
{
maxRequestedTimeStepIdx = tsId;
}
}
if (maxRequestedTimeStepIdx != cvf::UNDEFINED_SIZE_T
&& m_scalarResultsToAdd->size() <= maxRequestedTimeStepIdx)
{
m_scalarResultsToAdd->resize(maxRequestedTimeStepIdx + 1);
}
}
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx) for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
{ {
@ -909,6 +926,25 @@ public:
return true; return true;
} }
// Resize the timestep container
{
size_t maxRequestedTimeStepIdx = cvf::UNDEFINED_SIZE_T;
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
{
size_t tsId = m_requestedTimesteps[tIdx];
if (maxRequestedTimeStepIdx == cvf::UNDEFINED_SIZE_T || tsId > maxRequestedTimeStepIdx)
{
maxRequestedTimeStepIdx = tsId;
}
}
if (maxRequestedTimeStepIdx != cvf::UNDEFINED_SIZE_T
&& m_scalarResultsToAdd->size() <= maxRequestedTimeStepIdx)
{
m_scalarResultsToAdd->resize(maxRequestedTimeStepIdx + 1);
}
}
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx) for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
{ {
size_t tsId = m_requestedTimesteps[tIdx]; size_t tsId = m_requestedTimesteps[tIdx];