Commit 101da2ed authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

avoid segfault during app exit.

Since in applications using Python, Python may get finalized before all
VTK objects are released, we may encounter segfaults during exit. This
fixes that issue by ensuring that Python interpreter is initialized
before calling `Py_XDECREF`.
parent bc578bed
......@@ -57,7 +57,12 @@ vtkPythonAlgorithm::vtkPythonAlgorithm()
vtkPythonAlgorithm::~vtkPythonAlgorithm()
{
Py_XDECREF(this->Object);
// we check if Python is still initialized since the Python interpreter may
// have been finalized before the VTK object is released.
if (Py_IsInitialized())
{
Py_XDECREF(this->Object);
}
}
// This macro gets the method passed in as the parameter method
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment