Skip to content

Commit

Permalink
fix #2935: flow crash (#2940)
Browse files Browse the repository at this point in the history
* fix #2935

* clang format

* clang-format 11
  • Loading branch information
shaomeng committed Dec 21, 2021
1 parent c46a700 commit 928fab0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/vapor/VaporField.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class FLOW_API VaporField final : public Field {
//
void AssignDataManager(VAPoR::DataMgr *dmgr);
void UpdateParams(const VAPoR::FlowParams *);
void ReleaseLockedGrids(); // Supposed to be invoked at the end of each paintGL event.

//
// Find one index whose timestamp is just below a given time
Expand Down
2 changes: 2 additions & 0 deletions lib/flow/VaporField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,5 @@ const VAPoR::Grid *VaporField::_getAGrid(size_t timestep, const std::string &var
_recentGrids.insert(key, new GridWrapper(grid, _datamgr));
return grid;
}

void VaporField::ReleaseLockedGrids() { _recentGrids.clear(); }
7 changes: 5 additions & 2 deletions lib/render/FlowRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <iostream>
#include <sstream>
#include <cstring>
#include <cctype> // std::isspace
#include <random>
#include <algorithm>
#include <vapor/Progress.h>
Expand Down Expand Up @@ -49,7 +48,6 @@ std::string FlowRenderer::_getColorbarVariableName() const { return GetActivePar

int FlowRenderer::_initializeGL()
{
// First prepare the VelocityField
_velocityField.AssignDataManager(_dataMgr);
_colorField.AssignDataManager(_dataMgr);
_timestamps = _dataMgr->GetTimeCoordinates();
Expand Down Expand Up @@ -345,6 +343,11 @@ int FlowRenderer::_paintGL(bool fast)

_restoreGLState();

// Release grids that are acquired during this paint event
// before their DataMgr is destroyed by others.
_velocityField.ReleaseLockedGrids();
_colorField.ReleaseLockedGrids();

return rv;
}

Expand Down

0 comments on commit 928fab0

Please sign in to comment.