Skip to content

Commit

Permalink
Fixes #2950 - Python engine variables double free crash (#2955)
Browse files Browse the repository at this point in the history
* Fix #2950

* fix

* Fix #2950

* clang-format pre-push hook

* Fix #2950

* Documentation for CalcEngineMgr::Clean()

Co-authored-by: StasJ <stas708@gmail.com>
  • Loading branch information
clyne and StasJ committed Jan 6, 2022
1 parent 81a2167 commit 0e4813a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion apps/vaporgui/PythonVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ PythonVariables::~PythonVariables()

void PythonVariables::Update(bool internalUpdate)
{
if ((_scriptName == "") || (_dataMgrName == "")) {
VAPoR::DataStatus * dataStatus = _controlExec->GetDataStatus();
std::vector<string> dataMgrNames = dataStatus->GetDataMgrNames();

if ((_scriptName == "") || (_dataMgrName == "") || ((std::find(dataMgrNames.begin(), dataMgrNames.end(), _dataMgrName) == dataMgrNames.end()))) {
_reset();
_setGUIEnabled(false);
} else {
Expand Down
5 changes: 5 additions & 0 deletions include/vapor/CalcEngineMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class RENDER_API CalcEngineMgr : public Wasp::MyBase {
//
void ReinitFromState() { _sync(); }

//! Remove all functions added with AddFunction()
//!
//! \sa AddFunction()
void Clean() { _clean(); }

private:
const DataStatus *_dataStatus;
const ParamsMgr * _paramsMgr;
Expand Down
8 changes: 3 additions & 5 deletions lib/render/ControlExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ int ControlExec::OpenData(const std::vector<string> &files, const std::vector<st
// new data manager
//
if (_dataStatus->GetDataMgr(dataSetName)) {
_calcEngineMgr->Clean();
_dataStatus->Close(dataSetName);

vector<string> vizNames = _paramsMgr->GetVisualizerNames();
Expand Down Expand Up @@ -488,6 +489,7 @@ int ControlExec::OpenData(const std::vector<string> &files, const std::vector<st
for (int i = 0; i < appRenderParams.size(); i++) {
int rc = appRenderParams[i]->Initialize();
if (rc < 0) {
_calcEngineMgr->Clean();
_dataStatus->Close(dataSetName);
_paramsMgr->RemoveDataMgr(dataSetName);
SetErrMsg("Failure to initialize application renderer \"%s\"", appRenderParams[i]->GetName().c_str());
Expand Down Expand Up @@ -530,11 +532,7 @@ void ControlExec::CloseData(string dataSetName)

_paramsMgr->RemoveDataMgr(dataSetName);

// Rebuild the calculation engine from params database after removing
// the data set from the params database.
//
_calcEngineMgr->ReinitFromState();

_calcEngineMgr->Clean();
_dataStatus->Close(dataSetName);

UndoRedoClear();
Expand Down

0 comments on commit 0e4813a

Please sign in to comment.